I have a loop that fires off AJAX requests, is it possible to pause the loop until the AJAX has returned for each iteration?
for (var i = 0; i < 5; i++) {
var data = "i=" + 1;
var ajax = $.ajax({
url: '/ajax.php',
type: 'post',
data: data,
success: function(result)
{
//alert(result);
}
});
//pause the for loop here
ajax1.done(function (result) {
//continue the for loop
});
}