views:

1545

answers:

1

Hi.

I have a problem, when submitting a form all active ajax request fail, and that triggers error event.

How to stop all active ajax requests in jQuery without trigerring error event?

+7  A: 

Every time you create an ajax request you could use a variable to store it:

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

Then you can abort the request:

request.abort();

You could use an array keeping track of all pending ajax requests and abort them if necessary.

Darin Dimitrov
Yes, yes, and http://plugins.jquery.com/project/ajaxqueue can help.
umpirsky