몇 가지 자습서와 ajax/dataTables에 대한 설명서뿐만 아니라 SO에 대한 몇 가지 답변을 살펴 보았습니다. 내 dataTable은 여전히 JSON 데이터로 채워지지 않습니다.Codeigniter 및 Ajax로 dataTable을 채울 수 없습니다.
HTML :
<table id="table" class="table table-striped table-bordered table-hover" cellspacing="0" width="100%">
<thead>
<tr>
<th>Status</th>
<th>Student Name</th>
<th>Exam Name</th>
<th>School</th>
<th colspan="2">Action</th>
</tr>
</thead>
<tfoot>
<th>Status</th>
<th>Student Name</th>
<th>Exam Name</th>
<th>School</th>
<th colspan="2">Action</th>
</tfoot>
</table>
자바 스크립트 :
<script type="text/javascript">
$(document).ready(function() {
// Datatables
$('#table').DataTable({
"url": "<?php echo site_url('exams/ajax_list'); ?>",
});
});
</script>
시험 컨트롤러 ajax_list PHP 함수 :의로 json_encode 출력이 방법으로 탐색 할 때 내가 무엇을 볼 수에서
public function ajax_list() {
$list = $this->exam_model->get_datatables();
$data = array();
foreach ($list as $exam) {
$row = array();
$row[] = $exam->exam_status;
$row[] = $exam->first_name . " " . $exam->last_name;
$row[] = $exam->exam_name;
$row[] = $exam->exam_school;
$data[] = $row;
}
echo json_encode($data);
}
올바르게,하지만 dataTable은 여전히 비어 있습니다.
나는 무엇이 있습니까?
ajax_list의 경로를 두 번 확인 했습니까? – David