Jc John Jc John -4 years ago 82
Javascript Question

how can i get the value of this total from the ajax in this situation

i am using a codeigniter. Now i am wondering how to get this total from my controller something like success. Here is my data in network:

total

now what i want is to get total:0 to be alert with my ajax. how can i get it ? Here is my code in ajax in doing that post:

function data_table_report(dateselected){
$("#dataTables-report").dataTable().fnDestroy();

table = $('#dataTables-report').DataTable({
"ajax": {
"url": "<?php echo site_url('patients_report/dataTable_report/')?>"+dateselected,
"type": "POST",
},
responsive: true,
bInfo: false,
dom: 'Bfrtip',
buttons: [{ extend: 'colvis', columns: ':not(:first-child)'}],
success: function(total) {
alert(total);
}
});
}


i want to alert the total but i can't please help me.

Answer Source

Try hooking into dataSrc instead of success as success is used internally by Datatables . https://datatables.net/reference/option/ajax

"dataSrc": function ( json ) {
             alert(json.data.total);
           }
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download