Angularjs a cross-origin resource sharing (CORS) post or put method not working in IE8 and IE9

百般思念 提交于 2019-12-11 07:36:17

问题


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,


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/20671136/angularjs-a-cross-origin-resource-sharing-cors-post-or-put-method-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!