最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

bootstrap-paginator服務(wù)器端分頁使用方法詳解

 更新時間:2020年02月13日 15:14:03   作者:捂汗縣長  
這篇文章主要為大家詳細介紹了bootstrap-paginator服務(wù)器端分頁的使用方法,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了bootstrap-paginator服務(wù)器端分頁的基本用法,供大家參考,具體內(nèi)容如下

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>

 <!-- 主內(nèi)容列表 -->
 <ol class="list-group" id="infoList>
  <li class="list-group-item"><span class="fa fa-cog fa-spin fa-fw"></span>正在讀取數(shù)據(jù)……</li>
</ol>

<!-- 分頁導航器 -->
<div style="text-align:center;">
  <ul id="useroption" class="pagination"></ul>
</div>

JS:

//讀取消息列表*************************************************//
 queryInfoList(paraValue);
 function queryInfoList(bid)
 {
  $.ajax({
   async: true,
   type: "get",
   url: "../php/list.php",//向后端發(fā)送請求,后端為PHP
   dataType: "json", //要求后端返回數(shù)據(jù)為JSON格式
   data: { page: '1',bid:bid,act:'getInfoList' }, //請求參數(shù),首次請求頁碼為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; //當前頁數(shù)
    var pageCount = data.pageCount; //總頁數(shù)
  
    var options = {
     bootstrapMajorVersion: 4, //版本
     currentPage: currentPage, //當前頁數(shù)
     totalPages: pageCount, //總頁數(shù)
     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; //每頁條數(shù)
 $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];//總記錄數(shù)

 //計算總頁數(shù)
 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)));
}

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

施甸县| 甘泉县| 浙江省| 满洲里市| 蒙山县| 手游| 监利县| 商丘市| 黄冈市| 汕尾市| 中方县| 天镇县| 河西区| 札达县| 萨嘎县| 山阳县| 安龙县| 淄博市| 嫩江县| 景泰县| 华阴市| 清新县| 吉木萨尔县| 志丹县| 海阳市| 钟祥市| 南郑县| 黄骅市| 乳山市| 金秀| 桂平市| 麦盖提县| 平南县| 皋兰县| 紫云| 定州市| 湖南省| 灌阳县| 巫山县| 普宁市| 防城港市|