Loading local JSON file

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

    If you want to let the user select the local json file (anywhere on the filesystem), then the following solution works.

    It uses uses FileReader and JSON.parser (and no jquery).

    
    
    
    

    Json File

    Here is a good intro on FileReader: http://www.html5rocks.com/en/tutorials/file/dndfiles/

提交回复
热议问题