Loading local JSON file

前端 未结 23 2029
悲哀的现实
悲哀的现实 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:56

    $.getJSON is asynchronous so you should do:

    $.getJSON("test.json", function(json) {
        console.log(json); // this will show the info it in firebug console
    });
    

提交回复
热议问题