When I try to retrieve data from my database into a table, I get this error:
DataTables warning (table id = 'student_table'): Requested unknown parameter '1' from the data source for row 0
Below is the javascript that I used
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { $('#student_table').dataTable( { "bProcessing": true, "bServerSide": true, "sServerMethod": "POST", "sAjaxSource": "<?php echo base_url()?>index.php/data/all" } ); } ); </script>
Received JSON data:
{"sEcho":0,"iTotalRecords":3, "iTotalDisplayRecords":3, "aaData":[["85","t1","1D"],["74","test475","4A"], ["777","maiz","5"]],"sColumns":"id,name,class"}
The table below is:
<table class="datatable tables" id="student_table"> <thead> <tr> <th>ID</th> <th>Name</th> <th>Class</th> </tr> </thead> <tbody> <tr> <td class="dataTables_empty">Loading data from server</td> </tr> </tbody> </table>
PHP code (flammable data)
$this->load->library('datatables'); $this->datatables->select('admission,name,class'); $this->datatables->from('students'); echo $this->datatables->generate();
I use codeigniter and DataTables.
Why am I getting this error and how to retrieve data in a table?