I'm having some problems with the ajax async. I have an array then loop through the array to make an ajax call, if success the ajax will return an xml string, i'll use it to fill in an table and update process bar. I use async:false it works fine on Firefox, but it's not work properly on Chrome. I also tried to use $.ajax().done(), but it's not affect at all.
Is there anyway to get the responsed xml string when ajax call finish then the next loop will run?
for (var i = 0; i <= arr.length; i++){
$.ajax({
url: '',
data: '',
async: false
}).done(function(xml) {
//get xml string to handle and put it into some table as contents
});
//Then go to next loop
}
async/awaitandawaitthe call. Note that it still won't be synchronous, and will never be, and you need to adjust the remaining code accordingly.awaithere is distinctly suboptimal: There's no dependency of request 2 on request 1 so running them serially instead of in parallel will just be slow.