I want to detect cases where an Ajax call is in progress and then it is interrupted due to some user action (e.g. user navigating to another page)?
I can see that when this happens my onreadystatechange handler gets called with readyState == 4 (DONE) and status == 0.
The question is, is there any way to be sure that this really corresponds to the described scenario (request aborted due to user action)? I want to avoid masking other -potentially more dangerous- errors.
For the user navigating to another page you could use the
onbeforeunloadevent.For example: