您的位置:首页 > 理论基础 > 计算机网络

Ajax本地跨域问题 Cross origin requests are only supported for HTTP

2015-04-02 11:34 483 查看
问题:打开本地html文件时,报错如下

Cross origin requests are only supported for protocol schemes: http, data,chrome-extension, https, chrome-extension-resource.
分析:浏览器为了安全性考虑,默认对跨域访问禁止。

解决:给浏览器传入启动参数(allow-file-access-from-files),允许跨域访问。
Windows下,运行(CMD+R)或建立快捷方式:
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --allow-file-access-from-files
参考资料:

https://stackoverflow.com/questions/10752055/cross-origin-requests-are-only-supported-for-http-error-when-loading-a-local/23758738#23758738

来自为知笔记(Wiz)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐