1.首頁在控制也獲取分頁參數
$p = input("p/d",'0');
$list = db('Comment')->paginate(config('paginate.list_rows'),$count,['page'=>$p,'path'=>"javascript:void(0);"]);
$this->assign('commentlist',$list);// 商品評論
return $this->fetch();
<div class='dataTables_paginate paging_simple_numbers'>
{$commentlist->render()}
</div>
js
// 點擊分頁觸發的事件
$("#ajax_comment_return .pagination a").click(function(){
ajaxComment($(this).html());//獲取當前頁數
});
/***用ajax分頁顯示**/
function ajaxComment(page){
$.ajax({
type : "GET",
url:"/Index/Goods/ajaxComment?p="+page,//+tab,
success: function(data){
$("#ajax_comment_return").html('').append(data);
}
});
}