当我尝试从我的数据库表中检索数据,我得到这个错误:从数据源请求的未知参数“1” 0行中的数据表
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();
我使用笨和数据表。
为什么我得到该错误以及如何将数据检索到表中?
我尝试了GET和POST,但我得到了同样的错误。 – LiveEn
错误必须在php部分,你能证明吗? – JvdBerg
我已经添加了PHP代码(点燃datatables)的主要职位。 – LiveEn