我想在ajax调用后删除表中的行。这是我的代码:
function getResultsMsr(action, msrDel) {
if(action == 'search') {
$('#example').dataTable( {
"processing": true,
"serverSide": true,
"ajax": "testing_ajax.php",
"columnDefs": [
{
"aTargets":[7], // this your column of action
"mData": null,
"mRender": function(data, type, full){
var rowId= full[6];
return '<td id="row'+msrDel+'"><a href="javascript: void(0);" onclick="removeRow('+rowId+');" >Delete</a>
}
}
]
} );
这是我尝试删除行的删除函数:
function removeRow(msrDel){
var parent = $(this).parent().parent();
$.ajax({
url: 'getResult.php',
type: 'POST',
data: "id="+msrDel
}).done(function(result_data){
parent.fadeOut('slow', function() {$(this).remove();});
});
return false;
}
最佳答案
函数removeRow(msrDel){
var oTable = $('#example').dataTable();
var parent = $(this).parent().parent();
$.ajax({
url: 'getResult.php',
type: 'POST',
data: {
formName:'afscpMsr',
action:'delete',
delmsr: msrDel
}
}).done(function(result_data){
// parent.fadeOut('slow', function() {$(this).remove();});
oTable.fnDeleteRow( $('#example tbody tr:eq(0)')[0] );
});
return false;
}
关于php - 如何使用ajax jquery删除数据表的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25265198/