I am making a request and then right after it I abort.
var x = $.get(url, function (d, e, xhr) { alert(d); });
x.abort();
The problem is that it executes the success
function and returns empty data... (example here)
Is there a jQuery method to abort? or Is there a way to check if the xhr
was aborted?
The best way to detect request abortion and avoiding false positive from offline mode :
$("#loading").ajaxError(function(event, xhr) {
if (xhr.status === 0) {
if (xhr.statusText === 'abort') {
// Has been aborted
} else {
// Offline mode
}
}
});
I found here that the xhr
will return with status 0
. Seems to be a jQuery 1.4+ bug. On 1.3 it called the error handler.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With