"Origin null is not allowed by Access-Control-Allow-Origin" in Chrome. Why?

JavascriptGoogle ChromeXmlhttprequestCross Domain

Javascript Problem Overview


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);
 })
})

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.

Javascript Solutions


Solution 1 - Javascript

Chrome doesn't believe that there's any common relationship between any two local 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.

Solution 2 - Javascript

If you are using Mac OS X, open up the Terminal, cd to your web root and run:

python -m SimpleHTTPServer

Then open the following URL in Chrome (or any other web browser):

http://0.0.0.0:8000

Solution 3 - Javascript

It's like crossdomain for some unclear reason (each browser acts a bit differently regarding this issue, you could even try IE and see the results). You should try and run it through a web server, and give it an absolute path since the javascript runs locally.

Solution 4 - Javascript

You can try running it on your apache web server. It will work.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMossView Question on Stackoverflow
Solution 1 - JavascriptPointyView Answer on Stackoverflow
Solution 2 - JavascriptWebSeedView Answer on Stackoverflow
Solution 3 - JavascriptCu7l4ssView Answer on Stackoverflow
Solution 4 - JavascriptMadhukarahView Answer on Stackoverflow