admin管理员组文章数量:1389897
I have an asp web page and I want to populate the table with jquery, ajax web service call something. But I am not strong on it at all. The html part for the table is:
<tbody id="testBody">
<tr id="templateEquipment" class="hidden">
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td class="hidden">
</td>
</tr>
</tbody>
I already defined the columns and the table is empty at the beginning. And in jquery
function SearchEquipment() {
$.ajax({
type: "POST",
url: pageName + "SearchEquipment",
data: "{'oParams':" + JSON.stringify(BeginSearch()) + "}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
if (response.d.length > 0) {
$.each(response.d, function (i, item) {
<!-- add row to fill the table-->
Thanks for your help. I do not have the resources for that(links are weled).
I have an asp web page and I want to populate the table with jquery, ajax web service call something. But I am not strong on it at all. The html part for the table is:
<tbody id="testBody">
<tr id="templateEquipment" class="hidden">
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td class="hidden">
</td>
</tr>
</tbody>
I already defined the columns and the table is empty at the beginning. And in jquery
function SearchEquipment() {
$.ajax({
type: "POST",
url: pageName + "SearchEquipment",
data: "{'oParams':" + JSON.stringify(BeginSearch()) + "}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
if (response.d.length > 0) {
$.each(response.d, function (i, item) {
<!-- add row to fill the table-->
Thanks for your help. I do not have the resources for that(links are weled).
Share Improve this question asked Jul 13, 2012 at 12:58 user1108948user11089481 Answer
Reset to default 6You can do it like this.
var html = $.map(response.d, function (item, i) {
return "<tr><td>" + item.value1 + "</td><td>" + item.value2 + "</td></tr>";
}).join("");
$("#testbody").append(html);
By creating a big string with all the rows and cells in it you only need to add it once to the DOM which is a lot quicker!
本文标签: javascriptPopulate table with jqueryjsonStack Overflow
版权声明:本文标题:javascript - Populate table with jqueryjson - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744579824a2613851.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论