Possible Duplicate:
Multiple ajax calls inside a each() function.. then do something once ALL of them are finished?
How do I execute a function after I run ajax in for loop. Example here I have this ajax running in loop,
for (var countDevice = 0; countDevice<32; countDevice++){
var dataString="modbus="+(countDevice+1)+"_"+newDate+".xml";
$.ajax({
type: "POST",
url: "CalculateTable",
data: dataString,
dataType: "json",
//if received a response from the server
success: function( device, textStatus, jqXHR) {
//Do something
}
});
}
I want to make sure to only run this function below, only after the above for loop is finished.
function drawTable(){
//Do something
}
Can anyone give any idea on how to make it possible? Thanks for taking the time to read and answer.