Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 938
Moss Avatar asked Mar 07 '11 19:03

Moss


2 Answers

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.

like image 108
Pointy Avatar answered Sep 27 '22 22:09

Pointy


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 
like image 22
WebSeed Avatar answered Sep 28 '22 00:09

WebSeed