chrome通过file协议浏览html代码时,发送的ajax请求本地文件,会报跨域错误

来源:互联网 发布:ubuntu系统能做什么 编辑:程序博客网 时间:2024/06/08 02:07

XMLHttpRequest cannot loadfile:///E:/webs/extJS/ext-3.3.0/examples/csdn/combobox.txt?_dc=1414738973999.Cross origin requests are only supported for protocol schemes: http, data,chrome-extension, https, chrome-extension-resource.

解决办法是给chrome添加启动参数:--allow-file-access-from-files ,这样本地ajax请求就不会报跨域错误了。(注意如果给chrome添加多个启动参数,每个启动参数“--”之前要有空格隔开,如"C:\ProgramFiles\Google\Chrome\Application\chrome.exe" --allow-file-access-from-files

具体方法:在浏览器快捷方式上右键-属性-快捷方式-目标

0 0
原创粉丝点击