Possible Duplicate:
Combine 2 JSON objects in JQUERY
I’m creating a facebook app with node on the backend to get the album list and show the cover photo for each. It needs to be done with two calls, one to get a list of albums, another to get the cover photo with the id of a particular album
my code looks something like this
$('#main').on('click', '#albums', function() {
$.get('/albums', function(data) {
for (i = 0; i < data.data.length; i++) {
$.get('/cover-photo?id=' + data.data[i].cover_photo, function(dataz) {
data+=dataz;
});
}
console.log(data);
});
});
the reason I want it all in one object is because I’m using javascript templating and it’d be better to just have one object that has everything
If you want to combine this object for using tepmplate enging I will suggest you just add a another key with the same object so you can access all information of album and also with that each album cover photo object.
Like: