Page-based demo of AjaxPHP. 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 of all, let's look at the pagination in silence today. 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. okay, first, we are still the basic AJAX development framework:
The code is as follows:
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:
The code is as follows:
Header ("Content-type: text/html; charset = GBK"); // output encoding to avoid Chinese garbled characters
?>
Ajax paging demonstration