Ajax本地跨域

Failed to load file:///E:/sublime/demo/d3/data.csv: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

Ajax本地跨域问题——跨域请求仅支持协议方案:http, data, chrome, chrome-extension, https.

在地址栏中输入http://localhost/demo/d3/index1.html 会出现如下错误:

根据物理路径及请求的URL得知,需要把要运行的文件或者文件夹(例:d3)放置在C:inetpubwwwroot下面,然后以http://localhost/d3/index1.html或者以http://127.0.0.1/d3/index1.html访问,即可看到正常页面。

应该在服务器环境里运行含有ajax方法的页面,而不是直接通过浏览器打开,例如file协议。

原文地址:https://www.cnblogs.com/songya/p/8944418.html