【发布时间】:2016-01-21 22:39:15
【问题描述】:
单击调用 Ajax 以从数据中删除记录时,我在每一行中都有删除按钮。它正在从数据库中删除记录,删除记录后我想显示剩余数据并删除表中的特定行,但它正在更改分页并刷新整个表。
var owner_table = null;
$(document).ready(function () {
owner_table = $('#owners_table').DataTable();
});
function deletehouseowner(oid, rid) {
$.ajax({
dataType: "HTML",
type: "POST",
data: {
"oid": oid
},
url: "houseowner_delete.php",
success: function (msg) {
if (msg === "failure") {
} else {
event.preventDefault();
var table = 'owners_table';
var row = $(this).closest('tr');
var id = row.attr("id");
setTimeout(function () {
var siblings = row.siblings();
owner_table.row($('#row_' + rid)).remove().draw();
siblings.each(function (index) {
$(this).children().first().text(index + 1);
});
}, 100);
}
}
});
}
截图:
【问题讨论】:
标签: javascript jquery datatables