I\'m using a JSONP ajax call to load some content from a different domain, and all this stuff is executed if the user causes a \"mouseover\" on a button.
I can captu
Do not abort the request
Just store somewhere the jqXHR object returned by $.ajax()
theJqXHR = $.ajax(....
If the user cancel the request null the saved object
// user canceled
theJqXHR = null;
Finally when you receive the response (success
callback) the callback will compare the jqXHR object of the response with the saved object.
function successCallback(data, textStatus, jqXHR )
{
if( theJqXHR !== jqXHR )
{
// user canceled; discard the response
return;
}
// process the response
}
No jQuery errors.
As a general advice don't rely upon abort()
, even for regular ajax requests.
In any case you won't save resource on the server bacause the request you sent will be processed and there is no way to stop it. And a response will come back.
Some (older) browsers handle abort()
not properly.
Just "cache" the jqXHR object and handle the CANCEL scenario yourself.