怎么把后台传过来的Json拼成table 用Jquery ajax

如题所述

//url请求url param相应参数{key:param}
$.post(url,param,function(data){
    var text = "<table border='1'>";
    $.each(data,function(i){
        var obj = $(this);
        text += "<tr>"
        $.each(obj,function(key,val){
            text+="<td>"+obj[key]+"</td>";
        });
        text += "</tr>"
    });
    text += "</table>";
    $("#showtab").html(text);
},"json");


html

<div id="showtab"></div>

温馨提示:答案为网友推荐,仅供参考