問題描述
我正在開發一些 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.
這篇關于“Access-Control-Allow-Origin 不允許 Origin null"在鉻.為什么?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!