6

Is it possible to stop the current ajax request from within the jquery global event ajaxStart?

2 Answers 2

11

.ajaxStart doesn't have access to the xhr object. .ajaxSend does, however. You can stop it there. I don't know why you would want to do this, but remember that this is a global ajax event -- so this effectively stops all ajax requests(or at least those that don't have the global:false flag).

$('some-object').ajaxSend(function(e, xhr) { xhr.abort(); }); 
Sign up to request clarification or add additional context in comments.

Comments

3

FYI there's a third argument also which is the Ajax Options object used to create the request in case that is of help...

 | | \| / \/ $('some-object').ajaxSend(function(e, xhr, options) { xhr.abort(); }); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.