這篇文章主要為大家展示了“bootstrap-paginator服務器端分頁使用的示例分析”,內容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領大家一起研究并學習一下“bootstrap-paginator服務器端分頁使用的示例分析”這篇文章吧。

目前創新互聯已為上千多家的企業提供了網站建設、域名、虛擬主機、網站托管、服務器租用、企業網站設計、敖漢網站維護等服務,公司將堅持客戶導向、應用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協力一起成長,共同發展。
HTML:
<script src="../js/jquery-3.2.1.min.js"></script> <script src="../js/bootstrap.min.js"></script> <script src="../js/bootstrap-paginator.min.js"></script> <!-- 主內容列表 --> <ol class="list-group" id="infoList> <li class="list-group-item"><span class="fa fa-cog fa-spin fa-fw"></span>正在讀取數據……</li> </ol> <!-- 分頁導航器 --> <div > <ul id="useroption" class="pagination"></ul> </div>
JS:
//讀取消息列表*************************************************//
queryInfoList(paraValue);
function queryInfoList(bid)
{
$.ajax({
async: true,
type: "get",
url: "../php/list.php",//向后端發送請求,后端為PHP
dataType: "json", //要求后端返回數據為JSON格式
data: { page: '1',bid:bid,act:'getInfoList' }, //請求參數,首次請求頁碼為1
cache: false,
success: function (data)
{
lis = "";
for (eachRs in data.rs)
{//拼接對應<li>需要的值
lis += "<li class='list-group-item'><a title='"+data.rs[eachRs]['title']+"' class='newsLink' href='read.html?id="+data.rs[eachRs]['id']+"'>" + data.rs[eachRs]['title'] + "</a> <span class='text-muted pull-right'>"+data.rs[eachRs]['posttime']+"</span></li>";
};
$("#infoList").html(lis);
var currentPage = data.CurrentPage; //當前頁數
var pageCount = data.pageCount; //總頁數
var options = {
bootstrapMajorVersion: 4, //版本
currentPage: currentPage, //當前頁數
totalPages: pageCount, //總頁數
numberOfPages: 10,//分頁器顯示10條
shouldShowPage: true,//是否顯示該按鈕
itemTexts: function (type, page, current)
{
switch (type)
{
case "first":
return "首頁";
case "prev":
return "上頁";
case "next":
return "下頁";
case "last":
return "末頁";
case "page":
return page;
}
},
//點擊事件,用于通過Ajax來刷新整個list列表
onPageClicked: function (event, originalEvent, type, page)
{
$.ajax({
async: true,
url: "../php/list.php",
type: "get",
dataType: "json",
data: { page: page,bid:bid ,act:'getInfoList'},
cache: false,
success: function (data)
{
lis = "";
for (eachRs in data.rs)
{//拼接對應<li>需要的值
lis += "<li class='list-group-item'><a title='"+data.rs[eachRs]['title']+"' class='newsLink' href='read.html?id="+data.rs[eachRs]['id']+"'>" + data.rs[eachRs]['title'] + "</a> <span class='text-muted pull-right'>"+data.rs[eachRs]['posttime']+"</span></li>";
};
$("#infoList").html(lis);
}/*success*/
});
}
};
$('#useroption').bootstrapPaginator(options);
}/*success*/
});
}PHP:
if($act=='getInfoList')
{
$bid=addslashes($_REQUEST['bid']);
$curPage=addslashes($_REQUEST['page']);//當前頁碼
$pageSize=15; //每頁條數
$rsAll=$dbh->query("select count(id) from article where board=$bid and wid=30 and auditor is not null and accessable=1")->fetchAll();
$rsAllCount=$rsAll[0][0];//總記錄數
//計算總頁數
if($rsAllCount%$pageSize==0)
$pageAllCount=$rsAllCount/$pageSize;
else
$pageAllCount=intval($rsAllCount/$pageSize)+1;
$beginRs=($curPage-1)*$pageSize; //計算起始記錄
$curRsSql="select id,title, posttime from article where board=$bid and wid=30 and auditor is not null and accessable=1 order by posttime desc limit $beginRs,$pageSize";
$rsCur=$dbh->query($curRsSql)->fetchAll();
echo(json_encode(array("rs"=>$rsCur,"pageCount"=>$pageAllCount,"curPage"=>$curPage,"sql"=>$curRsSql)));
}以上是“bootstrap-paginator服務器端分頁使用的示例分析”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注創新互聯行業資訊頻道!
當前名稱:bootstrap-paginator服務器端分頁使用的示例分析
標題鏈接:http://www.yijiale78.com/article44/pehgee.html
成都網站建設公司_創新互聯,為您提供品牌網站設計、網站改版、網站收錄、App設計、網站設計公司、App開發
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯