In XHR, is it possible to distinguish network errors from cross-origin errors?

Posted by greim on Stack Overflow See other posts from Stack Overflow or by greim
Published on 2010-05-18T21:27:20Z Indexed on 2010/05/18 21:30 UTC
Read the original article Hit count: 173

Filed under:
|
|

http://www.w3.org/TR/access-control/

Reading the CORS spec linked above, it seems to be the case that it's impossible to reliably distinguish between a generic "network error" and a cross-origin access denied error. From the spec:

If there is a network error Apply the network error steps.

Perform a resource sharing check. If it returns fail, apply the network error steps.

http://www.w3.org/TR/access-control/#simple-cross-origin-request0

In my testing, I couldn't locate any features of Firefox's implementation that seem to indicate that the resource sharing check definitely failed. It just switches readyState to 4 and sets status to 0.

Ultimately I'd like the ability to pass a success callback, a general fail callback, and an optional cross-origin fail callback, to my function. Thanks for any help or insight.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about xhr