Php + ajax implementation of refreshing pagination

Source: Internet
Author: User
This article mainly introduces php + ajax implementation of the method of refreshing new pages. it describes in detail the creation of databases, the implementation of Ajax files, and the PHP call method, for more information about php + ajax, see the following example. 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 ("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

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: 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.