且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将JSON文件加载到JS对象中

更新时间:2022-06-02 22:01:50

你需要进行AJAX调用以获取文件。 $。getJSON 就是为了这个目的:

You need to make an AJAX call to get the file. $.getJSON was intended for exactly this purpose:

$.getJSON('./test.json', function(obj) {
    console.log(obj.details.ProductID);
});