首页 > 代码库 > Ajax本地跨域问题 Cross origin requests are only supported for HTTP
Ajax本地跨域问题 Cross origin requests are only supported for HTTP
问题:打开本地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 |
用这个方法必须关闭谷歌浏览器再执行才有效
Ajax本地跨域问题 Cross origin requests are only supported for HTTP
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。