DataTables warning: table id=main-data-table - Invalid JSON response.

DataTables warning: table id=main-data-table - Invalid JSON response.

Mengzz08Mengzz08 Posts: 1Questions: 1Answers: 0

Here is my Controller:
~~public function door_to_door($request_type = ""){
switch($request_type){
case "list" :
header("Content-Type: application/json");
$datatable = $this->get_datatable();

   $data['data'] = $this->admin->fetch_doortodoor_rate(
     $datatable['limit'],
     $datatable['offset'],
     $datatable['search']['value']
   );

   $data['draw'] = $datatable['draw'];
   $data['recordsTotal'] = $this->db->count_all('door_to_door_rates');
   $data['recordsFiltered'] = $this->crud->fetch_door_to_door_rate_count($datatable['search']['value']);

   echo json_encode($data);
   return;

}

$data['active']='rate_management';
$data['module_name'] = '';
    $data['company_contacts'] = $this->crud->get_company_contacts();
$this->load->view("door_to_door_rates",$data);

}~~

And here is my view script:
~~

Pickup Area Drop Off Area Rate
                </div>
            </div>
        </div>
    </div>
</div>
<script type='text/javascript'>

$("#main-data-table").DataTable({
  ajax: {
    url: ' <?= base_url()?>/admin/door_to_door/list',
    dataSrc:'data'
  },
  serverSide:true,
  columns: [
    {data: null, render:function(data,type,row){
      return row.start_area_name + ", " + row.start_province_name;
    }},
    {data: null, render:function(data,type,row){
      return row.end_area_name + ", " + row.end_province_name;
    }},
    {data: "rate"}
  ]
});

</script>~~

How can I fix the error?

Sign In or Register to comment.