0

so, i create Json data as question.json Json:

"Endokrynologia"[
    {   "title":"Endokrynologia",
        "id": "001",
        "date":"08J", 
        "question":"Niedoczynność przedniego płata przysadki u dorosłych mężczyzn nie powoduje:",
        "answear01": "zmniejszenia wydzielania TSH.",
        "answear02": "zmniejszenia wydzielania aldosteronu.",
        "answear03": "niepłodności.",
        "answear04": "zmniejszenia wydzielania kortyzolu.",
        "answear05": "niedoczynności tarczycy." }, 
        {
        "id": "002",
        "date":"11W", 
        "question":"30-letnia kobieta o dziecięcej budowie twarzy i zimnej suchej skórze, nie miesiączkuje. Stwierdzenie niskiego stężenia FSH, TSH i prolaktyny wskazuje na:",
        "answear01": "ciążę.",
        "answear02": "zespół przedwczesnego wygasania czynności jajników.",
        "answear03": "wszystkie prawdziwe.",
        "answear04": "nadczynność tarczycy.",
        "answear05": "niedoczynność przysadki mózgowej." }
]

and a call function with jquery:

$(document).ready(function(){
 $.getJSON('question.json', function(data) {
    //do stuff with your data here
});
});

but i get console error like:

Failed to load file:///C:/Users/Mirosz/Desktop/project/test2/question.json: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https

what i did wrong?! How to load that file?!

Piotr Mirosz
  • 846
  • 9
  • 20

3 Answers3

2

Use a server to run your code, like live-server or http-server.

Theer
  • 53
  • 5
1

My crystal ball says that you are loading the model using either file:// or C:/, which stays true to the error message as they are not http://

So you can either install a webserver in your local PC or upload the model somewhere else and use jsonp and change the url to http://example.com/path/to/model

jvk
  • 2,133
  • 3
  • 19
  • 28
0

Changing URL scheme to http resolves your problem.

The fast way I use sometime is, start a local development http server with python:

python -m SimpleHTTPServer

and test on http://localhost:8000/foo.html instead of file:///C:/.../foo.html

set0gut1
  • 1,652
  • 1
  • 8
  • 21