Reputation: 18857
Trying to learn jquery here so I took a regular javascript snippet that loops through a json collection like this:
for (var i in msg) {
alert(msg[i].Name);
}
In this case, the alert box displays the correct name.
However, if I use jquery like this:
$.each(msg, function(item) {
alert(item.Name);
});
alert box show undefined for each item in the json collection. What did I miss?
TIA.
Upvotes: 0
Views: 490
Reputation:
Use the second parameter.
// this one-------------v
$.each(msg, function(i, item) {
alert(item.Name);
});
Upvotes: 2