[jQuery] Nested getJSON
[jQuery] Nested getJSON
Here is my code:
$.getJSON("/cgi-bin/messages.cgi", { id: last_message },
function( json ) {
$.each( json.messages, function( i, item ){
if ( item.command == "new" ) {
$.getJSON("/cgi-bin/get_data.cgi", { id: item.id, fields: "all" },
function( json ) {
$.each( json.objects, function( i, item ){
create_object( item );
//return false;
});
});
} else if ( item.command == "change" ){
$.getJSON("/cgi-bin/get_data.cgi", { id: item.target, fields:
"all" }, function( json ) {
$.each( json.dp_objects, function( i, item ) {
update_object( item );
});
});
} else if ( item.command == "delete" ){
$(".object[id_num=item.target]").remove();
}
});
});