Jquery每个Json对象

我有一个一个服务返回的结果集,给我以下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",{"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>

我知道我错过了一些简单的东西

感谢您的帮助提前

解决方法

在提供给每个功能的内部,这是指当前元素。尝试这个:
$.each(result.GroupList,function() {
    $('#myTable > tbody').append(
        '<tr><td>'
        + this.userName
        + '</td><td>'
        + this.count +
        '</td></tr>'
    );
});

如果这对你不起作用,它可能与此有关:$(‘#myTable> tbody’),考虑到没有tbody元素。我相信Internet Explorer会自动创建一个,但其他浏览器不会。检查$.support.tbody以查看浏览器是否为您执行。

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...