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