jquery绑定数据

利用C#在后台拼装一个json格式的字符串,再用jquery解析json串,排版到tbody里.需求是如此简单

<script type="text/javascript" src="../../js/jquery-1.4.2.min.js"></script>
    <script type="text/javascript">
        $(function(){
            var str_Json = $("#StrJson").val();
            var str_table = "";
            var json_val = eval("("+str_Json+")");
            $.each(json_val.rows,function(index,item){
                str_table += "<tr><td>"+item.id+"</td><td>"+item.name+"</td><td>"+item.email+"</td><td>"+item.mobile+"</td></tr>";
            });
            $("tbody").append(str_table);
        })
    </script>

<table>
            <thead>
                <tr>
                    <th>编号</th>
                    <th id="memberName">姓名</th>
                    <th>邮箱</th>
                    <th>手机</th>
                </tr>
            </thead>
            <tbody>
               
            </tbody>
        </table>

你可能感兴趣的:(jquery,json,function,C#,table,手机)