0

This code works fine in FF and IE, but not in Chrome why?

$(document).ready(function(){
    $.getJSON("timline.js",function(result){
     alert(result);
  });
});

chrome error: Failed to load resource: Origin null is not allowed by Access-Control-Allow-Origin. file:///E:/jquery/parekh_timeline/timline.js

XMLHttpRequest cannot load file:///E:/jquery/parekh_timeline/timline.js. Origin null is not allowed by Access-Control-Allow-Origin.

Felix Kling
  • 795,719
  • 175
  • 1,089
  • 1,143
Kashif Hashmi
  • 75
  • 1
  • 2
  • 10
  • 1
    By the look of the error it's because you're running this via the filesystem, not through a loca server e.g. XAMPP. – Mitya Jan 30 '14 at 09:46

2 Answers2

2

It's famous Chrome bug.

Run local web server and use localhost. I'm using SimpleHTTPServer python module:

python -m SimpleHTTPServer

Or use Chrome flag --allow-file-access-from-files.

Alex
  • 11,115
  • 12
  • 51
  • 64
0

You need to host your files on a web server.

Hans
  • 2,610
  • 3
  • 17
  • 20