I am using a data table to display data from database and i can perform delete and edit actions.with below code i am able to fetch data from database and perform edit and delete. but the issue is when i delete particular row it is deleted from database but still it is displayed in data table. i made use of "table.destroy();"but it gives the following error. Uncaught TypeError: $.fn.DataTable.isDataTable is not a function.
code for datatable:
<script>
var table;
if($.fn.DataTable.isDataTable('#sun_project_table') ) {
table=$('#sun_project_table').DataTable();
table.destroy();
//$('#category_table_body').empty();
}
table=$('#sun_project_table').DataTable({
"aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
"iDisplayLength": <?php echo 10; ?>,
'bProcessing' : true,
'bServerSide' : true,
'sAjaxSource' : "<?php echo base_url();?>index.php/Registrationc/displayinfo8",
columns: [
{ "name": "van_village_mapping.van_id", "data": "van_id" },
{ "name": "van_village_mapping.village_id", "data": "village_id" },
{ "name": "Actions", "data": "Actions" }
],
"columnDefs": [
{
}],
"createdRow": function ( row, data, index ) {
},
'fnServerData': function(sSource, aoData, fnCallback)
{
aoData.push();
$.ajax
({
'dataType': 'json',
'type' : 'POST',
'url' : sSource,
'data' : aoData,
'success' : fnCallback
});
},
"oTableTools": {
"sSwfPath": "assets/media/swf/copy_csv_xls_pdf.swf",
},
"oLanguage": {
"sSearch": "Filter: "
}
});
});
</script>
<script>
function delete_van_village_mapping($1){
$.ajax({
type:"POST",
url: "<?php echo base_url(); ?>index.php/Registrationc/delete_van_village_mapping1",
data:{van_village_mapping_id:$1},
success: function()
{
alert('done!');
}
});
};
</script>