Reputation: 3770
I'm working with an API that sometimes doesn't set the right Access-Control headers for CORS requests.
How can I inform the user that something went wrong when an Access-Control error occurs? I don't even need to know what error occurred, just that the XHR request failed.
Wrapping the request in a try/catch block doesn't seem to work in WebKit browsers.
Upvotes: 0
Views: 360
Reputation: 1446
Using jQuery? You can attach global error handlers with $.ajaxError()
.
Upvotes: 0
Reputation: 8368
I would suggest attaching an onerror
handler to the XMLHttpRequest
instance.
Upvotes: 1