Chrome报错:Origin null is not allowed by Access-Cont

1.问题场景

    js中采用jQuery的$.getJSON或$.ajax等获取本地文件时,出现错误:

   

    

2.问题原因

    Origin null is not allowed by Access-Control-Allow-Origin的意思是由于安全原因浏览器不允许跨域访问。

    Chrome因为有安全沙箱,它认为加载本地其他文件为跨域访问


3.解决办法

  给Chrome添加启动参数--allow-file-access-from-files

    右键Chrome浏览器的快捷方式,选择“属性”,在“目标”中加入 --allow-file-access-from-files , 重启Chrome浏览器

    注:--allow-file-access-from-files 前面的空格

   Chrome报错:Origin null is not allowed by Access-Cont_第1张图片

4.问题延伸

   N/A


你可能感兴趣的:(chrome)