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!