1、使用 Ajax 方式获取
$.get(“json/test.json”, function(data) {
console.log(data.total);
});
1
2
3
另一种方式:
$.ajax({
type: “get”,
url: “json/test.json”,
dataType: “json”,
async: false,
success: function(data) {
console.log(data.total);
}
});
1
2
3
4
5
6
7
8
9
2、使用 getJSON 方式获取
$.getJSON(“json/test.json”, function(data) {
console.log(data.total);
})