Difference between failed (without network) and canceled request in ajax error (HTTP status code 0)

I am using jquery ajaxError to catch all ajax errors. I am having a problem with the status code http 0 . This code is returned when the request fails (no network), or if the user refreshes the page (or clicks on another tab). I want to distinguish between both. Is there any way to do this?

+4
source share
1 answer

I think there is no easy solution, but there is a workaround. In the status code http 0 you can check ...

if(navigator.onLine)

which will return if there is any network connected or not.

+2
source

Source: https://habr.com/ru/post/1486182/


All Articles