function RefreshTbody(action, searchVal) {
$.get('ajax.php', { action: action, value: searchVal }, function (data) {
var json = jQuery.parseJSON(data);
$(function () {
var content = '';
//content += '<tbody>'; -- **superfluous**
for (var i = 0; i < json.length; i++) {
content += '<tr id="' + json[i].ID + '">';
content += '<td><input id="check_' + json[i].ID + '" name="check_' + json[i].ID + '" type="checkbox" value="' + json[i].ID + '" autocomplete=OFF /></td>';
content += '<td>' + json[i].ID + '</td>';
content += '<td>' + json[i].Name + '</td>';
content += '<td>' + json[i].CountryCode + '</td>';
content += '<td>' + json[i].District + '</td>';
content += '<td>' + json[i].Population + '</td>';
content += '<td><a href="#" class="edit">Edit</a> <a href="#" class="delete">Delete</a></td>';
content += '</tr>';
}
// content += '</tbody>';-- **superfluous**
//$('table tbody').replaceWith(content); **incorrect..**
$('#myTable tbody').html(content); // **better. give the table a ID, and replace**
});
});
};
jquery refresh table data
最新推荐文章于 2022-08-24 14:15:11 发布