Phpajax paging 2 _ PHP Tutorial

Source: Internet
Author: User
Phpajax page 2. Ajax pagination phpaajax pagination javaajax pagination asp. netajax pagination jqueryajax pagination jspajax no-refreshing pagination aspajax pagination ajax implementation pagination ajaxjsp pagination followed by ajax pagination php ajax pagination java ajax pagination asp.net ajax pagination jquery ajax pagination jsp ajax No-refreshing pagination asp ajax pagination ajax implement pagination ajax jsp pagination
Next, let's look at the page. js code in the previous file,

Var Page = {
Url: '', // URL address
Method: 'GET ',
Display: '', // Default display by page | Default2 | custom
Plugins: '', // return JSON data. you need to use this function to format the custom function.
Pagep: '', // DIV displayed by 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', // 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. pagep = options. pagep;
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); // call the paging control function. In fact, there are three parameters that can be customized to create more paging styles.
}
Catch (e ){
Try {
Eval (Page. display) (pageno, totalpage, number );
}
Catch (e ){
Alert ('undefined paging control processing function' + 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 + = 'the current page has no records! ';
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 ))
Htmlstr + ='['+ (Page-1) * pagenums + p) +']';
Else
Htmlstr + = '[' + (page-1) * pagenums + p) + ']';
}
If (pageno = totalpage)
Htmlstr + = Page. nextpage;
Else
Htmlstr + = ''+ Page. nextpage + '';
If (page = pagenum)
Htmlstr + = Page. nextten;
Else
Htmlstr + = ''+ Page. nextten + '';
Htmlstr + = '[Total' + totalpage + 'page |' + number + 'records]';
}
$ (Ajaxp). innerHTML = htmlstr;
},
String: function (pageno, totalpage, number ){
Htmlstr = '';
If (number = 0) htmlstr + = 'the current page has no records! ';
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 + = '[Total' + totalpage + 'page |' + number + 'records]';
}
$ (Page. pagep). innerHTML = htmlstr;
}
} // End

This file is mainly used to achieve the paging effect.


Php ajax pagination java ajax pagination asp.net ajax pagination jquery ajax pagination jsp ajax without refreshing pagination asp ajax pagination problem ajax implement pagination ajax jsp pagination next...

Related Article

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.