How to stop ajax request

I use jquery to create ajax requests

$.ajax( url: "http://someurl.org", success: function() { ... } ); 

How can I manually stop my specific ajax request?

+7
source share
2 answers

The $.ajax() method returns an object that can be used for this:

 var xhr = $.ajax( url: "http://someurl.org", success: function() { ... } ); 

and then when you want to stop the request:

 xhr.abort(); 
+22
source

Ajax requests are HTTP transactions that were once made that cannot be stopped. You can stop the ajax request from starting, but not kill the already made request.

+4
source

All Articles