Ajax + PHP paging Program-PHP source code

Source: Internet
Author: User
Ec (2); Ajax + PHP paging demonstration, with source code download !! Today, let's look at the pagination in silence. Think about it as if no post has been posted in the original area for a long time. Let's extend it to a PHP + AJAX paging demonstration by the way. Okay, let's talk about it, first, we are still the basic AJAX development framework: copy the content to the clipboard code: varhttp_requestfalse; & nbsp; functionsend_request (url) {initialization, specifying the processing function script ec (2 ); script

Ajax + PHP paging demo with source code download !!
Today, let's look at the pagination in silence. Think about it as if no post has been posted in the original area for a long time. Let's extend it to a PHP + AJAX paging demonstration by the way. Okay, let's talk about it, first, we are still the basic AJAX development framework:
Copy content to clipboard
Code:
Var http_request = false;
Function send_request (url) {// initialization, specifying the processing function and sending the request function
Http_request = false;
// Start initializing the XMLHttpRequest object
If (window. XMLHttpRequest) {// Mozilla Browser
Http_request = new XMLHttpRequest ();
If (http_request.overrideMimeType) {// sets the MIME category
Http_request.overrideMimeType ("text/xml ");
}
}
Else if (window. ActiveXObject) {// IE browser
Try {
Http_request = new ActiveXObject ("Msxml2.XMLHttp ");
} Catch (e ){
Try {
Http_request = new ActiveXobject ("Microsoft. XMLHttp ");
} Catch (e ){}
}
}
If (! Http_request) {// exception. An error occurred while creating the object instance.
Window. alert ("An error occurred while creating the XMLHttp object! ");
Return false;
}
Http_request.onreadystatechange = processrequest;
// Determine the request sending method, URL, and whether to execute the following code synchronously
Http_request.open ("GET", url, true );
Http_request.send (null );
}
// Function for processing the returned information
Function processrequest (){
If (http_request.readyState = 4) {// judge the object status
If (http_request.status = 200) {// The message is returned successfully. Start to process the information.
Document. getElementById (reobj). innerHTML = http_request.responseText;
}
Else {// The page is abnormal.
Alert ("the page you requested is abnormal! ");
}
}
}
Function dopage (obj, url ){
Document. getElementById (obj). innerHTML = "reading data ...";
Send_request (url );
Reobj = obj;
}
I put the content in a p display. When the page flip action is generated, I use AJAX to update the DIV to achieve the page flip effect. This is the page code for displaying the content:
Copy content to clipboard
Code:
Header ("Content-type: text/html; charset = GBK"); // output encoding to avoid Chinese garbled characters
?>


Ajax paging demonstration

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.