Home  >  Article  >  Backend Development  >  php ajax pagination 2_PHP tutorial

php ajax pagination 2_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:05:52849browse

ajax paging php ajax paging java ajax paging asp.net ajax paging jquery ajax paging jsp ajax no refresh paging asp ajax paging ajax paging problem ajax paging implementation ajax jsp paging
Let’s continue the previous document to look at page.js code,

var Page = {
url:'',//URL address
method:'GET',
display:'',//Page display method Default || Default2 || You can also customize it Definition
Plugins:'', //Return JSON data, you need to use this function to format the custom function
pagediv:'', //DIV displayed with pagination characters
index:'[First page ]',
lastpage:'[previous page]',
nextpage:'[next page]',
endpage:'[last page]',
lastten:'[last 10 pages]',
nextten:'[Next 10 pages]',
javascript:'Page.Open',//It's very depressing~Function name
Send: function(method,url,pars, fun) {// Ajax connection initialization
new Ajax.Request( url,{method: method, parameters: pars, onComplete: eval('this.Result')});
},
Open: function(pageno){
SetCookie('pageno',pageno);
pars='pageno='+pageno;
url=this.url;
fun=this.display;
method=this.method;
Page.Send(method,url,pars,fun);
},
Init:function(url,options){
this.url=url;
this.display=options.display;
this.pagediv=options.pagediv;
this.Plugins=options.format;
pageno=GetCookie('pageno')?GetCookie('pageno'): 1;
this.Open(pageno);
},
Result:function(http) {
if(http.readyState == 4 ) {
if(http.status == 200) {
var response=http.responseText;
response=eval("("+response+")");
if(response.result) eval(Page.Plugins)(response.result) ;
pageno=parseInt(response.page.pageno);
totalpage=parseInt(response.page.totalpage);
number=parseInt(response.page.number);
try{
eval('Page.'+Page.display)(pageno,totalpage,number);//Calling the paging control function, there are actually three parameters to customize more paging styles
}
catch(e ){
try{
eval(Page.display)(pageno,totalpage,number);
}
catch(e){
alert('Undefined paging control handler' +Page.display);
}
}
}
}
},
number:function(pageno,totalpage,number) {
pagenums=10;
page=Math.ceil(pageno/pagenums);
pagenum=Math.ceil(totalpage/pagenums);
if(page==pagenum) nums=(totalpage-(pagenum-1)*pagenums); else nums=pagenums;
htmlstr='';
if(number==0) htmlstr+='There is no record on the current page! ';
else{
if(page==1) htmlstr+=Page.lastten;
else
htmlstr+=''+Page.lastten+'';
if(pageno==1) htmlstr+=Page.lastpage;
else
htmlstr+=''+Page.lastpage+'';
for( p=1;p<=nums;p++) {
htmlstr+='';
If(pageno==((page-1)*pagenums+p))
p)+']
';
        else
    htmlstr+='['+((page-1)*pagenums+p)+']< ;/span>';
}
if(pageno==totalpage)
htmlstr+=Page.nextpage;
else
htmlstr+=''+Page.nextpage+'';
if(page==pagenum)
htmlstr+= Page.nextten;
else
       htmlstr+=''+Page.nextten+'';
       htmlstr+='[共'+totalpage+'页|'+number+'条记录]';
  }
     $(Ajaxdiv).innerHTML=htmlstr;
 },
 string:function(pageno,totalpage,number) {
  htmlstr='';
   if(number==0) htmlstr+='当前页没有任何记录!';
      else{
      if(pageno==1) htmlstr+=' '+Page.index+' '+Page.lastpage;
         else{
       htmlstr+=' '+Page.index+' '+Page.lastpage+'';
    }
      if(pageno==totalpage) htmlstr+=' '+Page.nextpage+' '+Page.endpage+' ';
       else{
       htmlstr+=' '+Page.nextpage+' '+Page.endpage+' ';
    }
    htmlstr+='[共'+totalpage+'页|'+number+'条记录]';
  }
     $(Page.pagediv).innerHTML=htmlstr;
 }
}//结束

 

这个文件主要的作用就是实现在客气有分页效果喽.

 

 


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/445078.htmlTechArticleajax分页 php ajax 分页 java ajax分页 asp.net ajax分页 jquery ajax 分页 jsp ajax无刷新分页 asp ajax分页 ajax 分页问题 ajax实现分页 ajax jsp分页 下面接着...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn