Zia
0
Q:

jquery loop through json

var agents = [
               {
                  "id": "007",
                  "agent": "James Bond"
               },                  
               {
                  "id": "006",
                  "agent": "John Wick"
               }
             ]
// iterate over the JSON array
$.each(agents , function(index, item) { 
    console.log("Agent Id: " + item.id);
    console.log("Agent Name: " + item.agent);
});
0
var someObj = { foo: "bar"};

$.each(someObj, function(propName, propVal) {
  console.log(propName, propVal);
});
0

New to Communities?

Join the community