reqwest
reqwest copied to clipboard
CORS with IE8/9 gives SCRIPT5: Access is denied.
I am trying to make a CORS request and have it working in IE8/9. I get the error :
SCRIPT5: Access is denied.
The error occurs in the function getRequest
at the line that says
http.open(method, url, o['async'] === false ? false : true)
I have read this article http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx and I follow what is said there.
- I use the same protocol as the site
- I set the content type to
text/plain
- I don't add custom headers
Do I need something else?
Is the X-Requested-With: XMLHttpRequest
added and causing issues
How should I use the crossDomain
option in reqwest? Different for different browsers?
Thankful for any input....
Same issue here. Can't make cross-domain request on IE <= 9 even though the server is configured to allow all origins.
I have solved this. It was some time ago so I don't really remember but I think what you need to do is to set the option crossOrigin: true
in reqwest. Then you must set the header Content-Type: text/plain
. You can then put json in the body but you need to make sure that your back end can dezerialize it even though the header says text/plan
You can find an explanation at the very bottom of this page. http://msdn.microsoft.com/en-us/library/ie/cc709423(v=vs.85).aspx I think that goes for IE8 and 9 but from 10 and forward they came to their senses. But please verify that statement before basing an application on it =)
Hi @TheLudd - thanks for the tip. I tried following similar instructions prior to positing this without success in IE8, but I might have missed something.
Anyhow, I've switched to a different library (https://github.com/matthewwithanm/httpplease.js) which so far is working nicely.
Cheers
We've also ran into this issue. It was because the XHR target URL’s scheme/protocol did not match the scheme/protocol of the origin URL.
I suggest adding better error logging for these cases: https://github.com/ded/reqwest/pull/201