I have the following code which is giving me a Method POST, Status (canceled)
error message:
$(document).ready(function() {
var xhr = false;
I suppose that the problem is very easy. If you call xhr.abort();
then the error
callback of $.ajax
will be called for the pending request. So you should just ignore such case inside of error
callback. So the error
handler can be modified to
error: function(jqXHR, textStatus, errorThrown) {
var err;
if (textStatus !== "abort" && errorThrown !== "abort") {
try {
err = $.parseJSON(jqXHR.responseText);
alert(err.Message);
} catch(e) {
alert("ERROR:\n" + jqXHR.responseText);
}
}
// aborted requests should be just ignored and no error message be displayed
}
P.S. Probably another my old answer on the close problem could also interesting for you.