简体   繁体   English

AngularJS跨域资源共享(CORS)发布或放置方法不适用于IE8和IE9

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

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. 基本上,这是一个CORS问题,在添加标头后添加Access-Control-Allow-Origin“ *”在标头中添加Access-Control-Allow-Header“ Origin,X-Requested-With,Content-Type,Accept”标头添加Access-Control -Allow-Methods“ POST,GET,PUT,OPTIONS”到服务器配置文件中,我可以“ GET”数据,它适用于Chrome,但不适用于较低版本的IE。

Then I used JSONP to handle the problem of GET, it works for IE8 and IE9. 然后我使用JSONP处理GET问题,它适用于IE8和IE9。

Now, my question is how to get cross-origin resource sharing (CORS) post or put method not working in IE8 and IE9? 现在,我的问题是如何获取跨域资源共享(CORS)发布或放置方法在IE8和IE9中不起作用? Really have no idea, IE8 and IE9 has a bigger coverage. 真的不知道,IE8和IE9的覆盖面更大。

Keep getting the error: "Access is denied" 不断收到错误:“访问被拒绝”

Thanks, 谢谢,

CORS is not supported natively by IE9 or lower. IE9或更低版本本身不支持CORS。 You need to use a CORS polyfill, such as easyXdm . 您需要使用CORS polyfill ,例如easyXdm

You can find the list of supported browsers here . 您可以在此处找到受支持的浏览器列表。

IE 8 and 9 support CORS partially via their XDomainRequest object, which is not used on any other browser. IE 8和9通过其XDomainRequest对象部分支持CORS,该对象未在任何其他浏览器上使用。 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. AngularJS没有XDomainRequest,因此除非您使用某种polyfill,否则CORS在AngularJS(或jQuery)的IE 8/9上将无法工作。

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: 如果您只需要执行GET和POST(而不是PUT,DELETE等),并且不需要发送任何自定义标头,请包含此库以使CORS在IE 8和9上运行:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM