chrome支持本地ajax

来源:互联网 发布:网络炒作公司 编辑:程序博客网 时间:2024/05/06 19:05

chrome支持本地ajax

最近在调试本地Ajax请求时,会提示如下错误:

XMLHttpRequest cannot load file:///….
Origin null is not allowed by Access-Control-Allow-Origin.

这是因为 Chrome 不支持 Ajax 本地访问,参考

http://forum.jquery.com/topic/load-and-ajax-not-working-on-google-chrome

解决方案

1.问题仅存在于本地访问 Ajax;

2.在不改变代码的情况下,可在 Chrome 快捷方式中添加启动参数:

--allow-file-access-from-files(前面加空格);添加方法是:右键快捷方式,目标一栏中,后面添加。
0 0