我有一个结果集从服务返回,让我下面的JSONjQuery的每个JSON对象
{
"ThreadCount":61,
"GroupList":[
{"userName":"KLT","count":2687},
{"userName":"KCameron","count":718},
{"userName":"IRG","count":156},{"userName":"JLB","count":123},{"userName":"HML","count":121},{"userName":"SMN","count":99},{"userName":"TBridges","count":68},{"userName":"ARF","count":65},{"userName":"MarkGreenway","count":61},{"userName":"SMC","count":55},{"userName":"EMD","count":52},{"userName":"PKP","count":41},{"userName":"KBounds","count":36},{"userName":"MAN","count":33},{"userName":"LAC","count":17},{"userName":"EPS","count":17},{"userName":"CAN","count":7},{"userName":"MAJ","count":3},{"userName":"CPC","count":2}]
}
我想使用jQuery(或JavaScript把THREADCOUNT在一个DIV,并添加用户名和counds为表
success: function(result) {
$("#Unfiled").html(result.ThreadCount);
$.each(result.GroupList, function(user) {
$('#myTable > tbody').append(
'<tr><td>'
+ user.userName
+ '</td><td>'
+ user.count +
'</td></tr>'
);
});
}
出于某种原因,我没有得到我的表什么...
顺便说一句我的HTML是在这里:
<table>
<tr>
<td>
Unfiled Emails:
</td>
<td id="Unfiled">
-1
</td>
</tr>
<tr>
<td colspan="2">
<table id="myTable" border="2" cellpadding="3" cellspacing="3">
</table>
</td>
</tr>
</table>
我知道我失去了一些东西简单...
感谢您的帮助提前
您是否完全确定您收到了您所描述的答复?我注意到,你有没有填充计数器-1而不是61,好像服务器返回你错误的数据。 – 2009-10-15 00:00:43
抱歉误导你Artem ... -1是阿贾克斯发生之前有什么。 – MarkKGreenway 2009-10-15 05:12:08