0

I have Java Script file and i want do something after Ajax request/response is completed , so i found this function but i have multiple Ajax request/response and i want it to triger after all of theme completed.

$(document).ajaxComplete(function() {
  alert("Completed");
});

$(function main() {
  ...
  for (var i = 1; i < length; i++) {
    $.ajax({...});
});

How could i implement this?

2 Answers2

0

Use ajaxStop instead of ajaxComplete which fires on completion of each ajax request.

$( document ).ajaxStop(function() {

});
Arun P Johny
  • 384,651
  • 66
  • 527
  • 531
0

By using ajaxsend and ajaxstop to easyly identify the started ans ended.

$("document").bind("ajaxSend", function() {
               console.log("********ajax call started ********");
  }).bind("ajaxStop", function() {
               console.log("********ajax call stoped ********");
  }).bind("ajaxError", function() {
               console.log("********ajax call error ********");
  });
tamilmani
  • 591
  • 6
  • 13