/** 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> <span class= ' Pprev ' > prev </span> <span class= ' ppagestatr ' >1</span>/<span class= ' ptotal ' >1</span> <span class= ' Pnext ' > Next </span> <span class= ' PLast ' > Last </span> '; HTML+ = "<span> total </span><span class= ' rtotal ' >0</span><span> 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