【发布时间】:2017-05-29 05:42:04
【问题描述】:
我正在尝试使用数据表插件对我的数据进行分页,但它的分页仅在第一次工作。首先,当我点击第二页时它的负载显示数据它可以工作,但在那之后,它就不行了。它在表格顶部显示处理这是我的代码。
HTML
<table id="data_table" class="display" width="100%" cellspacing="0">
<thead>
<tr>
<th><input type="checkbox" id="selectAll"/></th>
<th>Plan Name</th>
<th>Description</th>
<th>Image</th>
<th>Quantity</th>
<th>Amount</th>
<th>Action</th>
</tr>
</thead>
<tbody></tbody>
</table>
JQUERY
$("#data_table").dataTable({
"bProcessing": true,
"bServerSide": true,
"bPaginate": true,
"sAjaxSource": "response.php",
});
PHP
if(isset($_GET['iDisplayStart']))
{
$start = $_GET['iDisplayStart'];
}
else
{
$start = 0;
}
if(isset($_GET['iDisplayLength']))
{
$limit = $_GET['iDisplayLength'];
}
else
{
$limit = 10;
}
$plan = new Plan();
$result = $plan->getPlanList($limit, $start);
$count= $plan->getCountPlanList();
$myarray['recordsTotal'] = $count[0]['count(*)'];
$myarray['recordsFiltered'] = $count[0]['count(*)'];
$myarray['draw'] = intval($start/$limit)+1;
$myarray['data'] ="";
foreach($result as $data)
{
$myarray['data'][] = array('<input type="checkbox" name="selectcheck[]" class="selectcheck" value="'.$data['id'].'">',$data['name'],$data['description'],$data['image'],$data['quantity'],$data['amount'],'<a href="">Edit</a>');
}
echo json_encode($myarray);
die;
【问题讨论】:
-
您的浏览器控制台是否出现任何错误?
-
在控制台上没有收到任何错误。在控制台上,它向服务器发送请求并获取数据,但未绘制数据
-
你要加
"pagingType": "full_numbers" -
$myarray['recordsTotal']和$myarray['recordsFiltered']的号码相同。 -
是的。两者都是相同的数字
标签: php jquery datatable datatables-1.10 jquery-pagination