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?
The read-only XMLHttpRequest. status property returns the numerical HTTP status code of the XMLHttpRequest 's response. Before the request completes, the value of status is 0. Browsers also report a status of 0 in case of XMLHttpRequest errors.
To Solve Flutter Web getting 'XMLHttpRequest' error while making HTTP call Error Most cases of this error just add Access-Control-Allow-Origin value in the header might resolve the issue. Just make sure to replace all Underscore by Dash.
This error is a Javascript error and it can be inspected from AndroidStudio terminal or from the browser console. If you run into this problem it means that the requests to the API server are failing due to a CORS error.
The read-only XMLHttpRequest.status property returns the numerical status code of the response of the XMLHttpRequest. status will be an unsigned short. Before the request is complete, the value of status will be 0.
It successfully contacted the server, the server reported that the resource wasn't found, the XMLHttpRequest instance properly received that report -- everything went fine. The error event only fires if something goes wrong with forming, parsing, or transmitting requests and responses, not if the response happens to be something you didn't want.
HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Responses are grouped in five classes: Informational responses (100–199) Successful responses (200–299) Redirects (300–399) Client errors (400–499) Server errors (500–599)
The read-only XMLHttpRequest.status property returns the numerical HTTP status code of the XMLHttpRequest's response. Before the request completes, the value of status is 0. Browsers also report a status of 0 in case of XMLHttpRequest errors.
onerror
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With