Stop ajax jquery request in ajaxStart

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

+5
source share
2 answers

.ajaxStartdoes not have access to the xhr object. .ajaxSend, However. You can stop him there. I don’t know why you would like to do this, but remember that this is ajax global event, so it actually stops all ajax requests (or at least those that don't have a flag global:false).

$('some-object').ajaxSend(function(e, xhr) {
    xhr.abort();
});
+7
source

FYI is the third argument, which is also an Ajax Options object, which is used to create a request in case this helps ...

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

All Articles