当我尝试将数据从我的数据库检索到表中时,我收到此错误:
DataTables warning (table id = 'student_table'): Requested unknown
parameter '1' from the data source for row 0
下面是我使用的javascript
<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>
检索到的 JSON 数据:
{"sEcho":0,"iTotalRecords":3,
"iTotalDisplayRecords":3,
"aaData":[["85","t1","1D"],["74","test475","4A"],
["777","maiz","5"]],"sColumns":"id,name,class"}
下面是我的表:
<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 代码(点燃的数据表)
$this->load->library('datatables');
$this->datatables->select('admission,name,class');
$this->datatables->from('students');
echo $this->datatables->generate();
我正在使用 codeigniter 和 DataTables。
为什么会出现该错误以及如何将数据检索到表中?