<script>
var tbodystr = "";$.ajax({ type: "get", url: "gettable.ashx", cache: false, datatype: "json", success: function(msg) { $.each(msg, function(i) { tbodystr = "<tr>"; tbodystr += "<td>" + msg[i]._0 + "</td>"; tbodystr += "<td>" + msg[i]._1 + "</td>"; tbodystr += "<td>" + msg[i]._2 + "</td>"; tbodystr += "</tr>"; $("#tbmain tbody").append(tbodystr); }); } });</script>
gettable.ashx文件
httpcontext.current.response.write(json.getjsondata(ds, keyfileds.tostring()));
大类的数据,就优化下看看
success: function(msg) { var tbodystr = []; $.each(msg, function(i) { tbodystr.push("<tr>"); tbodystr.push("<td>" + msg[i]._0 + "</td>"); tbodystr.push("<td>" + msg[i]._1 + "</td>"); tbodystr.push("<td>" + msg[i]._2 + "</td>"); tbodystr.push("</tr>"); }); $("#tbmain tbody").append(tbodystr.join(""));//join 将数组已某种形式连接起来 }