$.getJSON(
"/html/aijquery/JSON.js"
,
function
(d){
$.each(d,
function
(i,v){
$(
"body"
).append(i+
"."
+v.name+
":"
+v.link+
"<br>"
);
});
});
<script>
//假设我们有下面这样的一组json数据:
var
aijquery={
item1:{name:
"爱jquery"
,link:
"www.aijquery.cn"
},
item2:{name:
"学习jquery"
,link:
"aijquery.cn"
}
};
//可以直接用jquery里的$.each来遍历json:
$.each(aijquery,
function
(i,v){
document.write(i+
"."
+v.name+
":"
+v.link+
"<br>"
);
});
原文:https://www.cnblogs.com/aijquery/p/9190709.html