如下所示:
var obj=
[{id: 1, pId: 0, name: "采购商品", open: true}, {id: 2, pId: 1, name: "雨伞2", open: true}, {id: 2, pId: 1, name: "雨伞2", open: true}, {id: 2, pId: 1, name: "雨伞2", open: true}];
var x='';
$.each(obj, function (n, value) {
// alert(n + ' ' + value);
var trs = "";
trs += "<tr><td>" + value.name + "</td> <td>" + value.id + "</td></tr>";
x += trs;
});
$("#project").append(x);
以上这篇ajax获得json对象数组 循环输出数据的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持aitechtogether.com。