相思资源网 Design By www.200059.com

在Thinkphp目录的Lib\ORG\Util\目录里新建AjaxPage.class.php,写入一下内容:

<"").$this->parameter;
$parse = parse_url($url);
if(isset($parse['query'])) {
parse_str($parse['query'],$params);
unset($params[$p]);
$url = $parse['path'].'"<a id='big' href='javascript:".$this->ajax_func."(".$upRow.")'>".$this->config['prev']."</a>";
}else{
$upPage="";
}
if ($downRow <= $this->totalPages){
$downPage="<a id='big' href='javascript:".$this->ajax_func."(".$downRow.")'>".$this->config['next']."</a>";
}else{
$downPage="";
}
// << < > 
if($nowCoolPage == 1){
$theFirst = "";
$prePage = "";
}else{
$preRow = $this->nowPage-$this->rollPage;
$prePage = "<a id='big' href='javascript:".$this->ajax_func."(".$preRow.")'>上".$this->rollPage."页</a>";
$theFirst = "<a id='big' href='javascript:".$this->ajax_func."(1)' >".$this->config['first']."</a>";
}
if($nowCoolPage == $this->coolPages){
$nextPage = "";
$theEnd="";
}else{
$nextRow = $this->nowPage+$this->rollPage;
$theEndRow = $this->totalPages;
$nextPage = "<a id='big' href='javascript:".$this->ajax_func."(".$nextRow.")' >下".$this->rollPage."页</a>";
$theEnd = "<a id='big' href='javascript:".$this->ajax_func."(".$theEndRow.")' >".$this->config['last']."</a>";
}
// 1 2 3 4 5
$linkPage = "";
for($i=1;$i<=$this->rollPage;$i++){
$page=($nowCoolPage-1)*$this->rollPage+$i;
if($page!=$this->nowPage){
if($page<=$this->totalPages){
$linkPage .= "&nbsp;<a id='big' href='javascript:".$this->ajax_func."(".$page.")'>&nbsp;".$page."&nbsp;</a>";
}else{
break;
}
}else{
if($this->totalPages != 1){
$linkPage .= "&nbsp;<span class='current'>".$page."</span>";
}
}
}
$pageStr = str_replace(
array('%header%','%nowPage%','%totalRow%','%totalPage%','%upPage%','%downPage%','%first%','%prePage%','%linkPage%','%nextPage%','%end%'),
array($this->config['header'],$this->nowPage,$this->totalRows,$this->totalPages,$upPage,$downPage,$theFirst,$prePage,$linkPage,$nextPage,$theEnd),$this->config['theme']);
return $pageStr;
}
}
"htmlcode">
<"ORG.Util.AjaxPage");// 导入分页类 注意导入的是自己写的AjaxPage类
$credit = M('user');
$count = $credit->count(); //计算记录数
$limitRows = 5; // 设置每页记录数
$p = new AjaxPage($count, $limitRows,"user"); //第三个参数是你需要调用换页的ajax函数名
$limit_value = $p->firstRow . "," . $p->listRows;
$data = $credit->order('id desc')->limit($limit_value)->select(); // 查询数据
$page = $p->show(); // 产生分页信息,AJAX的连接在此处生成
$this->assign('list',$data);
$this->assign('page',$page);
$this->display();
}
}
"htmlcode">
<html>
<head>
<title>Ajax无刷新分页</title>
<script type="text/javascript" src="/UploadFiles/2021-04-02/jquery-1.7.2.min.js">

以上所述是小编给大家介绍的在Thinkphp中使用ajax实现无刷新分页的方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!

标签:
thinkphp,ajax无刷新分页

相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com

评论“在Thinkphp中使用ajax实现无刷新分页的方法”

暂无在Thinkphp中使用ajax实现无刷新分页的方法的评论...