使用$.each(data,function(i,n){});
可以用n.字段,取到想要的值。
$.ajax({
type: 'post',
url: '/XXX',
dataType: 'json',
success:function(data){
var item;
$.each(data,function(i,result){
item=
""+result['name']+" "+result['age']+" ";
$('.table').append(item);
});
},
});
然后将item打入table里
| name | age |
|---|
以上这篇Ajax返回的json遍历取值并显示到前台的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持考高分网。



