I have a script on some getJSON, please help the solution.
$.getJSON('data1_get.php', {dbase: 'file1', param: '0'}, function(data_1) {
$.getJSON('data2_get.php', {dbase: 'file2', param: '1'}, function(data_2) {
for (var i=0; i<data_1.length; i++) { // about 4 rows
for (var k=0; k<data_2.length; k++) { // about 7 rows
if (data_1[i].type == data_2[k].type) {
if (data_2[k].switch=="1") { // possible many process
// check.php needed time about 3 seconds for 1 process
$.getJSON('check.php', {param: data_2[k].turnOn}, function(data_3) {
// not work
if (data.status) {
alert('working for '+data_2[k].title);\n";
}
});
}
}
}
}
});
});
my question is : How can i force it to wait and not continue until we get all the call backs from the ajax requests ?
Thanks!