“Origin null is not allowed by Access-Control-Allow-Origin”在Chrome中。为什么? [英] "Origin null is not allowed by Access-Control-Allow-Origin" in Chrome. Why?

查看:599
本文介绍了“Origin null is not allowed by Access-Control-Allow-Origin”在Chrome中。为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一些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它说原始null不允许Access-Control-Allow-Origin。这意味着什么?我找到关于与此错误相关的跨服务器内容的各种线程,但我只是在处理本地文件。

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.

感谢上帝的主人尼克·克拉弗这个信息,当我基本上问同一个问题前一段时间。

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

这篇关于“Origin null is not allowed by Access-Control-Allow-Origin”在Chrome中。为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆