$(function () {
$("#btnDelete").click(function () {
var v;
var $check = $("#tableUserInfo :checkbox:checked");
$check.each(function () {
v = $(this).parents("tr").find("td").eq(1).text().trim();
});
$.ajax({
type: "post",
url: "/Handlers/UserInfo.ashx",
data: {
method: "DeleteUserInfo",
UserID:v
},
dataType: "json",
success: function (data) {
$.each(data, function (index, o) {
var s = "";
s += "<tr>";
s += "<td>";
s += "<input type='checkbox' name='ck' class='tree-checkbox' />";
s += "<td>" + o.UserInfo.UserID + "</td>";
s += "<td>" + o.UserInfo.UserName + "</td>";
s += "<td>" + o.UserInfo.Cellphone + "</td>";
s += "<td>" + o.DepartmentList.DeptName + "</td>";
s += "</td>";
s += "<td>";
s += "<img alt='' title='修改' onclick='UpdateUserInfo(" + o.UserInfo.UserID + ")' src='image/icon_Edit.gif'/>";
s += "<img alt='' title='删除' onclick='DeleteUserInfo(" + o.UserInfo.UserID + ")' src='image/icon_Delete.gif' />";
s += "</td>";
s += "</tr>";
$("#tableUserInfo tr:gt(0)").remove();
$("#tableUserInfo").append(s);
}
处理程序返回的dt里有5条数据
为什么界面只能显示下一页的第一条数据
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
3条回答 默认 最新
斯洛文尼亚旅游 2016-08-03 06:13关注$("#tableUserInfo tr:gt(0)").remove();
你这里不是添加一条就删除之后继续添加的了。。这句放到each循环外面$("#tableUserInfo tr:gt(0)").remove();///////////////// $.each(data, function (index, o) { var s = ""; s += "<tr>"; s += "<td>"; s += "<input type='checkbox' name='ck' class='tree-checkbox' />"; s += "<td>" + o.UserInfo.UserID + "</td>"; s += "<td>" + o.UserInfo.UserName + "</td>"; s += "<td>" + o.UserInfo.Cellphone + "</td>"; s += "<td>" + o.DepartmentList.DeptName + "</td>"; s += "</td>"; s += "<td>"; s += "<img alt='' title='修改' onclick='UpdateUserInfo(" + o.UserInfo.UserID + ")' src='image/icon_Edit.gif'/>"; s += "<img alt='' title='删除' onclick='DeleteUserInfo(" + o.UserInfo.UserID + ")' src='image/icon_Delete.gif' />"; s += "</td>"; s += "</tr>"; $("#tableUserInfo").append(s); }本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报