title: data table correct syntax of this ajax for data table/ other way
body: <p>I am having trouble with this in my code i am in the situation in which my code doesn't work good. Here it is.</p>
  
  <p>I am using a codeigniter from this, i am having a trouble from the situation with this code below where i want to alert the total and execute my data table data. I am populating my data table data from my controller,</p>
  
  <p>In the code below, i manage to alert the total but my data table is not working, it returns no data available</p>
  
  <pre><code>function data_table_report(dateselected){
          $("#dataTables-report").dataTable().fnDestroy();
  
          table =  $('#dataTables-report').DataTable({
              "ajax": {
                  "url": "&lt;?php echo site_url('patients_report/dataTable_report/')?&gt;"+dateselected,
                  "type": "POST",
                  "dataSrc": function (data) {
                    alert(data.total);
                    return data;
                  }
              },
              responsive: true,
              bInfo: false,
              dom: 'Bfrtip',
              buttons: [{ extend: 'colvis', columns: ':not(:first-child)'}]
          });
      }
  </code></pre>
  
  <p>but when i change my code with these below, my data table responds with data but it will not alert the total.</p>
  
  <pre><code>function data_table_report(dateselected){
          $("#dataTables-report").dataTable().fnDestroy();
  
          table =  $('#dataTables-report').DataTable({
              "ajax": {
                  "url": "&lt;?php echo site_url('patients_report/dataTable_report/')?&gt;"+dateselected,
                  "type": "POST",
  
              },
              responsive: true,
              bInfo: false,
              dom: 'Bfrtip',
              buttons: [{ extend: 'colvis', columns: ':not(:first-child)'}],
              "dataSrc": function (data) {
                    alert(data.total);
              }
          });
      }
  </code></pre>
  
  <p>what should i do to alert my total from ajax and also my data table will function well.</p>