I\'m trying to extract elements from a JSON file using javascript, however I\'m getting an error saying it can not load the JSON file.
This is what my code looks lik
Alternatively to installing web server or using 3rd party online environments you can just use different code editor - Brackets. It offers feature called "Live Preview". I just hit same error Uncaught XMLHttpRequest
with similar code, can confirm code works perfectly in Brackets.
Brackets works directly with your browser to push code edits instantly, so your browser preview is always up to date while you're coding — no page reloads needed. In order to keep your current web browsing unaffected, Brackets Live Preview opens an additional copy of Chrome using a separate Chrome profile. // From How to Use Brackets
Cross origin requests are only supported for HTTP.
Load the site over HTTP. Install a web server (such as Apache HTTPD or Lighttpd) if you need to.
d3.json is meant to load data through HTTP. As @Quentin said, you can set up a local server to serve the data over HTTP.
For development like this I use firefox, it seems to be more permissive when it comes to local cross origin requests than chrome. Alternatively you can use http://tributary.io/
Example with your code: http://tributary.io/inlet/5776228