問題描述
我正在開發(fā)一些 Javascript 以在我的 PC 上本地運(yùn)行.我正在使用 jQuery CSV 插件 (http://plugins.jquery.com/project/csv) 將 csv 文件加載到 javascript 數(shù)組中.腳本很簡單:
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".這意味著什么?我找到了各種關(guān)于與此錯(cuò)誤相關(guān)的跨服務(wù)器內(nèi)容的線程,但我只是在處理本地文件.
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 不認(rèn)為任何兩個(gè)本地文件之間存在任何共同關(guān)系.
Chrome doesn't believe that there's any common relationship between any two local files.
您可以使用--allow-file-access-from-files"選項(xiàng)啟動(dòng)它,告訴它您不同意.
You can start it with the option "--allow-file-access-from-files" to tell it you disagree.
感謝升天大師尼克·克拉弗(Nick Craver)在我前段時(shí)間問基本相同的問題時(shí)提供的信息.
Thanks to the ascendant master Nick Craver for this info when I asked essentially the same question some time ago.
這篇關(guān)于“Access-Control-Allow-Origin 不允許 Origin null"在鉻.為什么?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!