我正在使用 CORS POST 请求,并按照@ http://www.html5rocks.com/en/tutorials/cors/ 处理所有内容。
服务器将响应 header 设置为: 'Access-Control-Allow-Origin':'*' 我可以在 IE 开发工具中看到这个 header 值。
但在 IE10 浏览器上,我看到控制台消息为“SEC7118:http://的 XMLHttpRequest 需要跨源资源共享 (CORS)。
当我查看 Microsoft 网站时,它给出了以下解释。
http://msdn.microsoft.com/en-us/ie/dn423949(v=vs.94).aspx
SEC7118
描述: “[URL] 的 XMLHttpRequest 需要跨源资源共享 (CORS)。” XMLHttpRequest 是针对与您的页面域不同的域发出的。这要求服务器在其响应 header 中返回“Access-Control-Allow-Origin” header ,但没有返回。
建议修复: 服务器必须支持 CORS 请求并返回适当的“Access-Control-Allow-Origin” header 以及资源。有关响应 header 中 CORS 的详细信息,请参阅 IE10 中 XHR 的 CORS。
问题:
- 我想知道此控制台消息是否是错误??
- 这会导致任何失败吗?
- 为什么即使将响应 header “Access-Control-Allow-Origin”值设置为“*”后仍会收到此消息?
- “Access-Control-Allow-Origin”值是否必须是源名称 IE10可以工作吗?我知道 * 不是一个很好的选择,但是 IE 呢 需要准确的来源名称??
我对这些图像隐藏了 URL 和 cookie 详细信息。
最佳答案
来自MSDN :
Security error codes are in the form SEC7xxx [In IE]
与 SEC7118 相关:
An XMLHttpRequest was made to a domain that was different than your page's domain. This requires the server to return an "Access-Control-Allow-Origin" header in its response headers, but one was not returned.
Note This error code was removed in IE11 on Windows 10. It remains in IE11 for Windows 8.1 and Windows 7.
因此,从 IE 的 Angular 来看,它在技术上被视为一个错误,但肯定不是一个错误(因此它会消失)。 Access-Control-Allow-Origin 在资源上设置,但不一定与请求一起发回。如果指定的资源没有 Access-Control-Allow-Origin:*
(或域),则该资源将无法访问,服务器可能会返回 503 或 404,您会看到控制台中的真实错误消息类似于以下内容:
XMLHttpRequest cannot load http://example.com/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://blog.example.com' is therefore not allowed access.
关于javascript - SEC7118 : XMLHttpRequest CORS - IE Console message,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24646732/