I've read every spec I can find, even the W3 for ProgressEvents as well as XMLHttpRequest
, and I'm finding diddly regarding WHICH status codes (or What response) fire an Error event on an async XHR request. The most I can find is references to checking the status code itself on the object and handling that, which normally treats anything but 200 as an Error, yet a 3xx redirect from, say, a POST is not an Error (I can't recall if the XHR will follow a redirect automatically) Can someone help me out or point me in the right direction regarding the spec (no libraries) for all responses that initiate an onerror
event?
I've read every spec I can find, even the W3 for ProgressEvents as well as XMLHttpRequest
, and I'm finding diddly regarding WHICH status codes (or What response) fire an Error event on an async XHR request. The most I can find is references to checking the status code itself on the object and handling that, which normally treats anything but 200 as an Error, yet a 3xx redirect from, say, a POST is not an Error (I can't recall if the XHR will follow a redirect automatically) Can someone help me out or point me in the right direction regarding the spec (no libraries) for all responses that initiate an onerror
event?
1 Answer
Reset to default 7onerror
only fires for network-level events, which means that onload
will fire if there is a successful response, regardless of HTTP status code. See this question for more discussion: When should XMLHttpRequest's onerror handler fire