Khi tôi cố gắng để lấy dữ liệu từ cơ sở dữ liệu của tôi để bàn, tôi nhận được lỗi này:yêu cầu tham số chưa biết '1' từ nguồn dữ liệu cho hàng 0 trong DataTables
DataTables warning (table id = 'student_table'): Requested unknown
parameter '1' from the data source for row 0
Dưới đây là javascript mà tôi sử dụng
<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>
Các dữ liệu JSON lấy:
{"sEcho":0,"iTotalRecords":3,
"iTotalDisplayRecords":3,
"aaData":[["85","t1","1D"],["74","test475","4A"],
["777","maiz","5"]],"sColumns":"id,name,class"}
Dưới đây là bảng của tôi:
<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>
mã PHP (datatables đốt cháy)
$this->load->library('datatables');
$this->datatables->select('admission,name,class');
$this->datatables->from('students');
echo $this->datatables->generate();
Tôi đang sử dụng CodeIgniter và DataTables.
Tại sao tôi nhận được lỗi đó và cách truy xuất dữ liệu vào bảng?
tôi đã thử cả GET và POST nhưng tôi gặp lỗi tương tự. – LiveEn
Lỗi phải nằm trong phần php, bạn có thể chỉ ra điều đó không? – JvdBerg
tôi đã thêm mã php (dữ liệu được kích hoạt) vào bài đăng chính. – LiveEn