Loading local JSON file

前端 未结 23 1628
悲哀的现实
悲哀的现实 2020-11-22 01:28

I\'m trying to load a local JSON file but it won\'t work. Here is my JavaScript code (using jQuery):

var json = $.getJSON("test.json");
var data = e         


        
23条回答
  •  长发绾君心
    2020-11-22 01:38

    If you have Python installed on your local machine (or you don't mind install one), here is a browser-independent workaround for local JSON file access problem that I use:

    Transform the JSON file into a JavaScript by creating a function that returns the data as JavaScript object. Then you can load it with

提交回复
热议问题