javascript 仅在 Chrome 中出错:XMLHttpRequest 加载资源失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31756602/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error in Chrome only: XMLHttpRequest failed to load resource
提问by Craig
I am running a WebApi and a WebClient application under IIS express (localhost) and receive this error only when I run them under Chrome. It works fine under IE.
我正在 IIS express (localhost) 下运行 WebApi 和 WebClient 应用程序,并且仅当我在 Chrome 下运行它们时才会收到此错误。它在 IE 下工作正常。
At this point I am attempting to just log in a user and I receive two error messages that I am not sure what they mean -
此时,我正在尝试仅登录用户,但收到两条错误消息,我不确定它们的含义 -
Failed to load resource: http://localhost:59822/api/accounts/loginthe server responded with a status of 401 (Unauthorized)
加载资源失败:http://localhost:59822/api/accounts/login服务器响应状态为 401(未授权)
XMLHttpRequest cannot load http://localhost:59822/api/accounts/login. Invalid HTTP status code 401
XMLHttpRequest 无法加载http://localhost:59822/api/accounts/login。无效的 HTTP 状态码 401
采纳答案by reker-
This most likely happens due to the security settings in Chrome.
这很可能是由于 Chrome 中的安全设置造成的。
By default the same-origin policyis rigorously enforced.
默认情况下,严格执行同源策略。
Hereis how to disable it in Chrome.
这是在 Chrome 中禁用它的方法。