0

I have a Highchart html page that have to load a json file. I whant to do that localy and i try to use this to do so

 $.getJSON('data.json', function(data) {....}

Of course date.json is in the same directory and well populated but i have this error every time

Cross origin requests are only supported for protocol scheme

I tried a lot of thing but didn't found what i want. i think something simple can fixe it but i can't figure out how to

thor
  • 15
  • 7

2 Answers2

1

You should run it in a webserver, and access the JSON object with http:// and not with file://

jmtb
  • 36
  • 3
  • yes that work like i said that was easy. I just do a little `npm install http-server` – thor Mar 02 '16 at 18:15
0

Please see this answer for assistance.

You could use something like requireJS and the text loader plugin to load the local data file. I have not seen an instance of someone trying to load data with jQuery's getJSON() call from a local source; use a server to host your data, even a local one will do, if you want to use the jQuery method.

Community
  • 1
  • 1