Answer the question
In order to leave comments, you need to log in
How to run a double js ajax request loop?
Hello. I have the following problem.
You need to parse an XML file.
I parse it with something like this function (I omitted some details, such as filling in the progress bar, so that the essence is clearer):
function parsing(iterationObject, numberObjects) {
return $.ajax({
url: "parse.php",
method: "GET",
success: function(data) {
if (iterationObject <= numberObjects) {
iterationObject++;
parsing(iterationObject, numberObjects);
}
}
});
}
Answer the question
In order to leave comments, you need to log in
async: true
By default, all requests are sent asynchronously (i.e. true). If you want to send requests synchronously, set to false. Synchronous requests may block the browser for the duration of the request.
Try to write
function parsing(iterationObject, numberObjects) {
return $.ajax({
url: "parse.php",
method: "GET",
success: function(data) {
if (data.hasImages){
parsingImages(image, numberImages, iterationObject );
} else
if (iterationObject <= numberObjects) {
iterationObject++;
parsing(iterationObject, numberObjects);
}
}
});
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question