Loading local JSON file

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

    Try is such way (but also please note that JavaScript don't have access to the client file system):

    $.getJSON('test.json', function(data) {
      console.log(data);
    });
    

提交回复
热议问题