I want to delete the row of the table after the ajax call. Here my code:
我想在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>
}
}
]
} );
Here is my delete function what I have tried for delete the row :
这是我的删除功能,我试图删除行:
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;
}
1 个解决方案
#1
0
function 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;
}
#1
0
function 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;
}