jquery Ajax Paging 2

Source: Internet
Author: User

/** Paging $ ("#divPager"). flexipager* 2015.03.17*///Initialize list Default properties(function($) {$.addflex=function(t, p) {if(T.pager)return false;//return if the Pager-div object already existsp =$.extend ({URL:false,//get the URL address for the data sourceAsynctrue,//default asynchronous Load (false= synchronization)Method: ' POST ',//How data is sentDataType: ' JSON ',//types of data loads, JSONPage:1,//Current PageNewp:1,//default Current PageTotal:1,//total number of pagesRp:2,//default number of results per pageSortname: "",//Sort FieldsSortOrder: "",//ASC DESCPrimaryKey: "",//primary key field nameColoursevent: ""//Interface Rendering}, p); $ (T). Show (). attr ({cellpadding:0, cellspacing:0, border:0}). removeattr (' width ')); varg = {            //page OutBuildpager:function() {                //g.pdiv = document.createelement (' div ');                //g.pdiv.innerhtml = ' <div class= ' pDiv2 ' ></div> ';                //Alert ($ (g.pdiv). html ());                //Alert ($ (this.pdiv). html ());            varhtml = "<span class= ' Pfirst ' > Home </span>&nbsp;<span class= ' Pprev ' > prev </span>&nbsp; <span class= ' ppagestatr ' >1</span>/<span class= ' ptotal ' >1</span>&nbsp;<span class= ' Pnext ' > Next </span>&nbsp;<span class= ' PLast ' > Last </span>&nbsp;&nbsp;&nbsp; '; HTML+ = "<span> total &nbsp;</span><span class= ' rtotal ' >0</span><span>&nbsp; records </ Span> ";                $ (t). append (HTML); $('. Pfirst ', T). Click (function() {g.changepage (' first ') }); $('. Pprev ', T). Click (function() {g.changepage (' prev ') }); $('. Pnext ', T). Click (function() {g.changepage (' next ')) }); $('. PLast ', T). Click (function() {g.changepage (' last ')) });  This. populate (); },            //Get DataPopulatefunction() {                if(P.page >p.pages) P.page=p.pages; varparam =[{name:' Page ', Value:p.newp}, {name:' RP ', VALUE:P.RP}, {name:' Sortname ', Value:p.sortname}, {name:' SortOrder ', Value:p.sortorder}, {name:' PrimaryKey ', Value:p.primarykey}];                    $.ajax ({type:p.method, Url:p.url, Async:p.async, Data:param, Success:function(data) {data= "[" + Data + "]"; varpage = eval (data) [0].page; varTotal = eval (data) [0].total; varJSON = eval (data) [0].rows; P.pages= Math.ceil (parseint (total)/2); $(". Ptotal", T). html (p.pages);//pages$ (". Rtotal", T). html (total);//Total Records$ (". Ppagestatr", T). html (p.page);//Current Page                        //alert (JSON);                        if(p.coloursevent) p.coloursevent (JSON); }, Error:function(data) {alert ("Error:"); Try {                        } Catch(e) {alert ("Error:"));            }                    }                }); },            //pageChangepage:function(CType) {//alert (CType);                Switch(CType) { Case' First ':                        //p.page = P.NEWP = 1;P.NEWP = 1;  Break;  Case' Prev ':                        if(P.page > 1) P.NEWP= parseint (p.page)-1;  Break;  Case' Next ':                        if(P.page <p.pages) P.newp= parseint (p.page) + 1;  Break;  Case' Last ': P.newp=p.pages;  Break; }                if(P.NEWP = =p.page)return false; P.page=P.NEWP;  This. populate ();        }        };        G.buildpager (); T.P=p; T.pager=G; if(P.url &&p.autoload) {g.populate (); }        returnT;        }; vardocloaded =false;//Document loading complete identity$ (document). Ready (function() {docloaded =true }); varURLString = Document.location.pathname;//the URL of the current page    varHuayingpagerpnum = urlstring + "-huayingpagerpnum";//sets the number of pagination bars for the current page    //constructor Function$.fn.flexipager =function(p) {return  This. each (function() {            if(!docloaded) {                $( This). Hide (); vart = This; $ (document). Ready (function() {$.addflex (T, p);}); } Else{$.addflex ( This, p);    }        }); };}) (jQuery);varHyajax ={eventajax:function() {}, Executeajax:function(RequestType) {varXMLHTTP =NewActiveXObject ("Microsoft.XMLHTTP"); Xmlhttp.onreadystatechange=Hyajax.eventajax Xmlhttp.open ("")    }}
<script src="Etos_js/plugin/jquery/jquery-1.8.2.min.js"Type="Text/javascript"></script> <script src="Etos_js/jspager/jspager.js"Type="Text/javascript"></script> <script type="Text/javascript">$ (document). Ready (function () {$ ("#divPager"). Flexipager ({URL:"/handlers/topics.ashx? Action=get_answerlist", Sortname:"Createtime", SortOrder:"desc", coloursevent:adddata});        }); function AddData (JSON) {alert (JSON+"3234");//Returns a JSON data to parse the data}</script>

jquery Ajax Paging 2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.