使用数据表显示记录时我没有问题。问题是当我单击“下一个/上一个”按钮时,它将路由到“ 404页面未找到”。 我的js代码:
$.ajax({
url : "position/load_position",
method : "POST",
dataType: "json",
success : function (data) {
$('#position_list').html(data);
$('#position_data').dataTable( );
},
});
我的php代码:
public function load_position()
{
$position = $this->position_model->fetch_position();
$output = '';
$output .= '
<div class="table-responsive table-responsive-data2">
<table id="position_data" class="table " cellspacing="0" width="100%">
<thead class=" ">
<tr>
<th>ID</th>
<th>position</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
';
if ($position->num_rows() > 0) {
foreach ($position->result_array() as $row) {
$output .= '
<tr>
<td>' . $row['position_id'] . '</td>
<td>' . ucfirst($row['position']) . '</td>
<td><a title="Edit" href="#" class=" text-warning h5"><i class="fa fa-edit"></i></a></td>
<td><a href="#" title="Delete" class="text-danger h5 delete_position"><i class="fa fa-trash"></i></a></td>
</tr>
';
}
}
$output .= '
</tbody>
</table>
</div>
';
echo json_encode($output);
}
答案 0 :(得分:0)
检查Ajax网址
$.ajax({
type : "POST",
url : "<?php echo site_url(); ?>/controllerName/FunctionName"
});