“Access-Control-Allow-Origin 不允许 Origin null"在铬.为什么?

我正在开发一些 Javascript 以在我的 PC 上本地运行.我正在使用 jQuery CSV 插件 (http://plugins.jquery.com/project/csv) 将 csv 文件加载到 javascript 数组中.脚本很简单:

I am working on some Javascript to run locally on my PC. I am using a jQuery CSV plugin (http://plugins.jquery.com/project/csv) to load load a csv file into javascript arrays. The script is simple:

$(function(){
 $.get("file.csv", function(data){
  stuff = $.csv()(data);
 })
})

在 Firefox 中它可以正常工作,但在 Chrome 中它显示Access-Control-Allow-Origin 不允许 Origin null".这意味着什么?我找到了各种关于与此错误相关的跨服务器内容的线程,但我只是在处理本地文件.

In Firefox it works fine but in Chrome it says "Origin null is not allowed by Access-Control-Allow-Origin". What does that mean? I find all sorts of threads about cross-server stuff related to this error but I am just working with local files.

推荐答案

Chrome 不认为任何两个本地文件之间存在任何共同关系.

Chrome doesn't believe that there's any common relationship between any two local files.

您可以使用--allow-file-access-from-files"选项启动它,告诉它您不同意.

You can start it with the option "--allow-file-access-from-files" to tell it you disagree.

感谢升天大师尼克·克拉弗(Nick Craver)在我前段时间问基本相同的问题时提供的信息.

Thanks to the ascendant master Nick Craver for this info when I asked essentially the same question some time ago.

相关文章