O
O
Orehouse2014-02-28 08:03:32
JavaScript
Orehouse, 2014-02-28 08:03:32

How to access local JSON file?

There is an HTML page that needs to be filled with data from a JSON file located on the same machine.
I'm trying to get data using but the browser console swears: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. . How can I get data from 'storage.json'?
$.getJSON('storage.json');

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
Nikolai Vasilchuk, 2014-02-28
@Anonym

Google "File Access" and "Filesystem API"
You can start from here www.html5rocks.com/ru/features/file_access
and from here www.html5rocks.com/ru/tutorials/file/dndfiles

Y
Yakov Akulov, 2014-02-28
@jakulov

Try to use some kind of web server to get a json file from a URL like
localhost/storage.json
if the page is loaded from the url //localhost/index.html - you can get it like this
$.getJSON('/storage.json');

I
Insayt, 2014-03-01
@Insayt

I solved this problem by launching the project on Denver :) The file will have a url where you can get it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question