Suppose I have a somewhat long jQuery Ajax call (say 5 seconds) as follows:
$.ajax({
url: '/LongCall',
type: 'POST',
async: true,
cache: false,
datatype: 'json',
success: function(data) {
alert('Success!');
},
error(xhr, textStatus, errorThrown) {
alert('Error!');
}
});
Now suppose that, waiting for my five-second process to start, the user becomes impatient and decides to hit some kind of navigation on my page. What happens in the above call, the user receives an error message when he clicks the link.
I want the error message to be displayed if there really is an error, but if all that happened is that the user decided to leave, I do not want the error message to be displayed. How can i do this?
, - , (xhr.status, ?), , , , , ?
!