Thank you, Michael. Of course, the display loop has to be nested
inside the inner getJSON.
$.getJSON(friendsURL, function(friends){
$.getJSON(repliesURL, function(replies){
friends = $.merge(friends, replies);
$.each(friends, function(item){
// Display the item.
}); // each
Here's an even better set of console.log() calls:
$.getJSON(friendURL, function(friends){
console.log( 1, friends.length );
$.getJSON(replyURL, function(replies){
console.log( 2, friends.length );
$.extend(friends, replies);
console.log( 3, friends.length );
});
consol
Put some console.log() calls in your code and run it with Firebug enabled:
$.getJSON(friendURL, function(friends){
console.log(1);
$.getJSON(replyURL, function(replies){
console.log(2);
$.extend(friends, replies);
console.log(3);
});
console.log(4);
$.each(friends,
3 matches
Mail list logo