Page Pagination Method:
Ajax gets data from the background and pages in the foreground
$.ajax ({type: "POST", Url:API_CONFIG.getNews, Data:JSON.stringify (params), DataType: "JSON", ContentType: ' Application/json;charset=utf-8 ', success:function (data) { if (data! = NULL) {if (data. STATUS = = True) {var newslist = data. DATA; var count = data. COUNT; var PageCount = Math.ceil (count/pagesize); if (null! = Newslist && "! = newslist) {var html =" "; for (i = 0; I<Newslist.length; i++) {html += ' <div class= ' advisorycenter_news_mould ' > '; HTML += ' <div class= ' advisorycenter_news_picture ' > '; HTML += ' '+ Newslist[i].imgurl + ' "/>'; HTML + = '</Div>'; HTML + = '<Divclass= "Advisorycenter_news_text">'; HTML + = '<Divclass= "Advisorycenter_news_title">'; HTML + = '<ahref= "News.html?id= ' + newslist[i].id + '">' + Newslist[i].newstitle + '</a>'; HTML + = '</Div>'; HTML + = '<Divclass= "Advisorycenter_news_information">'; HTML + = '<span>' + Newslist[i].newsoriginate + '</span>'; HTML + = '<span></span>'; HTML + = '<span>' + Newslist[i].newstype + '</span>'; HTML + = '<span>' + Newslist[i].starttime + '</span>'; HTML + = '<span></span>'; HTML + = '</Div>'; HTML + = '<Divclass= "Advisorycenter_news_article">' + Newslist[i].newsdesc + '</Div>'; HTML + = '</Div>'; HTML + = '</Div>'; } HTML + = '<Divclass= "M-style m-box"></Div>‘; $ (' #newsList '). HTML (HTML);//Paging $ (". M-box "). Pagination ({pagecount:pagecount, coping:true, Current:pageindex, homepage: ' Home ', EndPage: ' Last ', Prevcontent: ' last page ', nextcontent: ' next page ', Callback:function (API) {Pagecallback (API); } });} else {document.getElementById (' newslist '). InnerHTML = "No Data"} } else {layer.msg ("", {time:1500, Content:data. MSG}); }} else {layer.msg ("", {time:1500, con Tent: ' Service exception '}); }}, Error:function () {layer.msg ("", {time:1500, Content: ' Query news Failed '}); } });
Page Flipping method
Paging calls function Pagecallback (API) { var pageIndex = api.getcurrent ()//Get Current Code querynewslist (PageIndex); }
jquery's Paging plugin Pagination.js