Parse Json data with JQuery

JavaScript has builtin functionality to read JSON objects.

Let’s say there is a json like:


[ { "id" : "1", "name" : "test1" },
{ "id" : "2", "name" : "test2" },
{ "id" : "3", "name" : "test3" },
{ "id" : "4", "name" : "test4" },
{ "id" : "5", "name" : "test5" } ]


It can be accessed in jQuery with following


$.each(results, function(index) {
 alert(results[index].id + ':' + results[index].name);
});

Leave a Reply

Your email address will not be published.