Question

Basically im using jqXHR with asmx. I want to do this if its possible;

Overally in everypage im using 6-7 ajax calls with sync or async depends on which method it is. But when one of them got error i want to break that ajax call and after the all of ajax calls.

Thanks already!

Was it helpful?

Solution

use an array to store the returned object from each ajax call, and iterate over that array to abort them all:

var XHR = []
........//later
var myajax = $.ajax({
    type: 'GET',
    url: url
}).done(function() {
    //do something
}).fail(function() {
   abortAll();
});
XHR.push(myajax);

function abortAll() {
   XHR.each(function(i,e) {
      e.abort();
   });
}

OTHER TIPS

Every time you create an ajax request it returns an object, you can use it to abort the request:

var request = $.ajax({
    type: 'POST',
    url: url,
    success: function(data){}
});

and then use the request to abort the call:

request.abort();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top