how to loop through JSON array in jQuery?

jquery, json, loops

Solution

Your array has default keys(0,1) which store object `{'com':'some thing'}` use:

var obj = jQuery.parseJSON(response);
$.each(obj, function(key,value) {
  alert(value.com);
}); 

Problem

I have a PHP page from which I get response in JSON: ``` [{'com':'something'},{'com':'some other thing'}] ``` I want to loop it and append each to a div. This is what I tried: ``` var obj = jQuery.parseJSON(response); $.each(obj.com, function(key,value) { alert(key+':'+value); } ``` This alerts as `undefined`, and also response is the JSON array..

Original source