[ad_1]
There are many questions and answers related to send data with ajax request in datatable jquery. But I didn’t find how to send data when default datatable delete button clicked in ajax request
I know this is confusing so I show you some code and images
$('#sample_data').on('draw.dt', function(){
$('#sample_data').Tabledit({
url:'action2.php',
dataType:'json',
columns:{
identifier : [1, 'sub_category_id'],
editable:[[5, 'GST'], [6, 'price'],
[8, 'Commission'], [10, 'discount']]
},
restoreButton:false,
onSuccess:function(data, textStatus, jqXHR)
{
if(data.action == 'delete')
{
$('#' + data.id).remove();
$('#sample_data').DataTable().ajax.reload();
}
}
});
});
see this is default code of datatable jquery for edit or deleting data.
now I also show you initialized datatable jquery code
$(document).ready(function(){
var dataTable = $('#sample_data').DataTable({
"processing" : true,
"dom": "<'row'<'col-sm-3'l><'col-sm-2'<'#selecttype'>><'col-sm-3'<'#activelist'>><'col-sm-4'f>>" +
"<'row'<'col-sm-12't>>" +
"<'row'<'col-sm-6'i><'col-sm-6'p>>",
"serverSide" : true,
"order" : [[1,"asc"]],
"ajax" : {
url:"action2.php",
type:"POST",
data: { <<-------------=
fetch: "fetch",
"status" : function(){
try{
console.log("trying ... ");
return document.querySelector("#activelistbox").value;
}catch(e){
console.log("message "+e);
return "Active List";
}
},
"type" : function(){
try{
console.log("trying ... ");
return document.querySelector("#selectbox").value;
}catch(e){
console.log("message "+e);
return "All";
}
}
}
}
}
};
see here I use data parameter to send data.
now I show you table image
This is payload data
payload data image
Now please tell me how can i send data
[ad_2]