Angularjs a cross-origin resource sharing (CORS) p

2019-07-27 00:51发布

Basically it is a CORS problem, after adding Header add Access-Control-Allow-Origin "*" Header add Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept" Header add Access-Control-Allow-Methods "POST, GET, PUT, OPTIONS" into server config file, I can "GET" data, it works for Chrome but not for lower version IE.

Then I used JSONP to handle the problem of GET, it works for IE8 and IE9.

Now, my question is how to get cross-origin resource sharing (CORS) post or put method not working in IE8 and IE9? Really have no idea, IE8 and IE9 has a bigger coverage.

Keep getting the error: "Access is denied"

Thanks,

2条回答
Explosion°爆炸
2楼-- · 2019-07-27 01:13

IE 8 and 9 support CORS partially via their XDomainRequest object, which is not used on any other browser. AngularJS doesn't XDomainRequest, so CORS won't work on IE 8/9 with AngularJS (or jQuery for that matter) unless you use some kind of polyfill.

If you only need to do GET and POST (not PUT, DELETE, etc.) and you don't need to send any custom headers, include this library to get CORS working on IE 8 and 9:

https://github.com/intuit/xhr-xdr-adapter

查看更多
狗以群分
3楼-- · 2019-07-27 01:21

CORS is not supported natively by IE9 or lower. You need to use a CORS polyfill, such as easyXdm.

You can find the list of supported browsers here.

查看更多
登录 后发表回答