P
P
Partizanin2015-12-07 14:39:59
JavaScript
Partizanin, 2015-12-07 14:39:59

Is it possible to read json file using jquery?

Is it possible to read a json file with jquery or javascript or ember js on the client side without a raised server?
If so, how?

There is a method in jquery

$.getJSON( "ajax/test.json", function( data ) {
}

when i try to use it it crashes to my console
Cross origin requests are only supported for protocol schemes

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Syomka Gavrilenko, 2015-12-07
@Partizanin

If I understand you correctly, here is jquery.getjson
To disable the error:
If the browser is chrome: in chrome it is possible to disable this check by starting the browser with the key
Then local files will be picked up.
And also I advise you to read:
Different protocols are regarded as different resources.
If you need authoritative sources, then you need to read the points from here tools.ietf.org/html/rfc6454 or www.w3.org/Security/wiki/Same_Origin_Policy

D
Dmitry Belyaev, 2015-12-07
@bingo347

With the help of AJAX
, if you are developing locally, then what will then lie on the server - raise the server locally
if you need to read exactly the local file - use FileApi

S
Stanislav Romanov, 2015-12-07
@Kaer_Morchen

I advise you to pay attention to Json Server

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question