Php + ajax implements the method of refreshing pagination, ajax pagination. Php + ajax implements the method of refreshing new pages. This document describes how php + ajax implements the method of refreshing new pages. Share it with you for your reference. The specific implementation method is as follows: this is a php + ajax method to achieve no refreshing paging, ajax paging
The example in this article describes how php + ajax implements a non-refreshing paging method. Share it with you for your reference. The specific implementation method is as follows:
This is a paging program instance based on the original ecology of php + js + ajax. we will create a detailed example from the database to js, php, the creation of html pages tells you how to call data by ajax page.
The procedure is as follows:
1. create a database
The SQL statement is as follows:
The code is as follows:
Create table 'TB _ user '(
'Id' int (10) not null auto_increment,
'Username' varchar (50) not null,
Primary key ('id ')
) ENGINE = MyISAM default charset = utf8 AUTO_INCREMENT = 10;
Insert into 'TB _ user' VALUES (1, 'AAA ');
Insert into 'TB _ user' VALUES (2, 'BBB ');
Insert into 'TB _ user' VALUES (3, 'CCC ');
Insert into 'TB _ user' VALUES (4, 'ddd ');
Insert into 'TB _ user' VALUES (5, 'Eee ');
Insert into 'TB _ user' VALUES (6, 'fff ');
Insert into 'TB _ user' VALUES (7, 'GGG ');
Insert into 'TB _ user' VALUES (8, 'hhh ');
Insert into 'TB _ user' VALUES (9, '�� ');
II. the ajaxpage. js file code is as follows:
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 ...";
Reobj = obj;
Send_request (url );
}
III. php call code:
The code is as follows:
PHP + ajax paging demonstration