0

I'm using JQuery: $.getJSON() to load a json data file on my computer.

I get the error:

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

How do I get around this problem.

13
  • 1
    Are you trying to load a file from your own computer? If so, JavaScript is not allowed to access your computer's file system for security reasons. Commented Mar 25, 2014 at 19:28
  • it is from my own computer! so does this mean there is absolutely no way it can happen? Commented Mar 25, 2014 at 19:29
  • @No1_Melman: The only way for JavaScript to read a file from your computer is if you use an <input type="file" /> and you select the file. There is no other way. Also, just FYI: AJAX only works with a web server. You can't AJAX to/from your local computer (file:///) Commented Mar 25, 2014 at 19:30
  • Are you using 'file://'? If so, that isn't going to work since javascript can't just access a file on your computer. Commented Mar 25, 2014 at 19:30
  • 1
    I suggest you set up a WAMP server on your machine. Without a webserver, you cannot make AJAX calls. Commented Mar 25, 2014 at 19:38

1 Answer 1

1

There is no way at the moment to get around this without using a web server.

Due to a security protocol.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.