karax icon indicating copy to clipboard operation
karax copied to clipboard

The callback to ajax can give a status of ``0`` due to xhr

Open dom96 opened this issue 6 years ago • 1 comments

This case should be handled, see here https://stackoverflow.com/questions/36416389/why-does-my-xmlhttprequest-have-readystate-4-but-status-0

dom96 avatar Apr 16 '18 16:04 dom96

How should it be handled though? A status of 0 just means a (client-side) error, and according to that StackOverflow post the easiest way to figure out what the error was is to look at the JS console and see what it says.

(And yes I realize it's been over three years since you wrote this, so you may not even remember why you ran into this issue :laughing:)

ajusa avatar May 02 '21 21:05 ajusa

From a quick look at the thread, it seems like the best option might be to add an onerror handler to the call that throws an exception.

geotre avatar Mar 02 '23 20:03 geotre

I've investigated this a bit more, and it seems there is no way to get details of the error from onerror so it is a bit useless. If you need to handle this case just check status == 0 in your callback.

If you have any other suggestions for how to approach this better please reopen the issue

geotre avatar Mar 09 '23 17:03 geotre