jqery和pagination分页的主要js代码

<script>
       var pageIndex = 0;     //页面索引初始值  
       var pageSize = 2;     //每页显示条数初始化,修改显示条数,修改这里即可
        $(function() {
            GetData( 0, "", "id desc");
           
            //分页参数设置
            $("#Pagination").pagination(<%= pageCount %>, {
            callback: pageselectCallback,
            prev_text: "« 上一页",
            next_text: "下一页 »",
            items_per_page:pageSize,
      num_display_entries:3,
      current_page:pageIndex,
      num_edge_entries:3
           });
          
            function pageselectCallback(page_id, jq) {
           //alert(page_id); 回调函数,进一步使用请参阅说明文档
           GetData(page_id,"","id desc");
        }  
        function GetData( pageIndex, strWhere, Orderby) {
        $("#result").html("");
            var Thehtml="";
            $.ajax({
                contentType: "application/json",
                type: "Post",
                dataType: "json",
                url: "WebService/WebService1.asmx/GetContents",
                data: "{'pagesize':" + pageSize+ ",'currentpage':" + pageIndex + ",'strWhere':'" + strWhere + "','orderBy':'" + Orderby + "'}",
                success: function(data) {
                    var $json = JSON.parse(data.d);
                    $.each($json, function() {
                        Thehtml = "<tr class=\"tr_bg\">";
                        Thehtml += "<td align=\"center\"><span class=\"checkall\"><input type=\"checkbox\"  id=\"rptList_ctl02_cb_id\"></span></td>";
                        Thehtml += "<td align=\"center\"><span id=\"rptList_ctl02_lb_id\">" + this["Id"] + "</span></td>";
                        Thehtml += "<td><a href=\"Edit.aspx?id=" + this["Id"] + "\">" + this["Title"] + "</a></td>";
                        Thehtml += "<td align=\"center\"></td>";
                        Thehtml += "<td align=\"center\">" + this["SortId"] + "</td>";
                        Thehtml += "<td align=\"center\"><span><a href=\"edit.aspx?id=" + this["Id"] + "\">修改</a></span></td>";
                        Thehtml += "</tr>";
                        $("#result").append(Thehtml);
                    })
                }
            });
        };


    })


  
   
    </script>

原文地址:https://www.cnblogs.com/fengkuangkg/p/3047669.html