How can I get javascript to read from a .json file?

前端 未结 5 1777
-上瘾入骨i
-上瘾入骨i 2020-12-01 00:48

My script currently looks like this:



        
5条回答
  •  悲&欢浪女
    2020-12-01 01:36

    Actually, you are looking for the AJAX CALL, in which you will replace the URL parameter value with the link of the JSON file to get the JSON values.

    $.ajax({
        url: "File.json", //the path of the file is replaced by File.json
        dataType: "json",
        success: function (response) {
            console.log(response); //it will return the json array
        }
    });
    

提交回复
热议问题