Php+ajax implementation of a non-refresh page example (with demo source download), ajaxdemo_php tutorial

Source: Internet
Author: User
Tags php database

Php+ajax implementation of a No-refresh page example (with demo source download), Ajaxdemo


The example in this paper describes the method of Php+ajax to implement no-refresh paging. Share to everyone for your reference, as follows:

Note : Some of the class libraries used here can find the source code in the previous article, so in order to shorten the length of the article, the link is indicated.

This article explains: Ajax implementation of no refresh paging, implementation principle, code display, code download.

Here are some facts to note:

1, Ajax does not refresh the benefits of the page: to provide a good customer experience, through Ajax in the background from the database to obtain data and display, to suppress the waiting to load the page to appear blank state;

2, then, Ajax no Refresh page is run on dynamic page (. php)? or a static page (. html/.htm/.shtml)? The answer is: static page;

3, the realization principle: through the front-end JS script program and the Ajax combination obtains the data which returns from the dynamic page, and displays.

OK, here's a code explanation:

Now that we are running on a static page, we first create a static HTML page, and the index.html code listing is as follows.

Index.html

 
   
 
  Ajax Implementation No Refresh page  Data Loading ...

Code listing, we have loaded an Ajax class library, which can be found in the previous article, "A simple Ajax class library and use method instance analysis"

In this static page, only a "data load ..." is displayed, and there is no data. At this point, we need a JS script to get the data from the database via Ajax. The JS script is as follows:

Reading the above code carefully, you will find the following phenomenon:

1, Setpage (pagenum) is a data extraction from the database JS function interface;
2, Ajax is through the article.php file to obtain data;
3, article.php?page=xx, here xx is to obtain the page number data,
Setpage (1): is to obtain the 1th page of data;
Setpage (2): is to obtain the 2nd page of data;
Setpage (100): is to obtain the 100th page of data;
......

So, how do you get data from the article.php file? Take a look at the code listing below.

article.php

<?php/*** $Id: article.php* author lee.* last modify $Date: 2012-01-21 16:53:05 $*/require_once './config.inc.php '; $m = New Model (); $page = new Ajaxpage ($m->total (' article '), 20); $m->total (' article ') gets the number of records for the article table, 10 for each page 10 $result = $m->fetchall (' article ', ' * ', ', ', ', $page->limit); Take out the data, ^_^, it's easy. Echo '
 
 
  
  '; Echo '
  
  '; Echo '
  
  '; foreach ($result as $v) {echo " 
   ";} Echo ' 
   '; Echo ' 
  

Huaqiang Electronic Network Information

ID Title Author Source Date
{$v [' id ']} {$v [' title ']} {$v [' Author ']} {$v [' source ']} {$v [' Date ']}
'. $page->fpage (). '
';? >

article.php data is connected in the previous article from the Huaqiang electronic network captured information data, because the data is relatively large, the code package download will be attached to the Article.sql file, so that you can test.

The data displayed on the static page index.html is the echo code in the article.php file.
The config.inc.php file in the code file mainly defines constants, such as: Database user name, database password, host ..., Database connection class library (Db.class.php), and Database Operations Class library (Model.class.php), please refer to the article PHP's PDO Common class Library example analysis, with the use of the method.

Program:

Mark the place to pay attention to

In this way, Ajax no-refresh paging is complete. There is also a ajaxPage.class.php in the program does not explain, in fact, the use of this Ajaxpage class library is the same as the normal paging class library.

That is: $page = new Ajaxpage (total number of records, displayed per page);

Please download the code to read the specific details.

Full instance code click here to download this site.

Read more about PHP related content readers can view the topic: "Php+ajax Tips and Applications Summary", "PHP operation and operator Usage Summary", "PHP Network Programming Skills Summary", "PHP Basic Grammar Primer Tutorial", "PHP operation Office Document Tips Summary ( including word,excel,access,ppt), PHP date and Time usage summary, PHP Primer for object-oriented programming, PHP string usage Summary, PHP+MYSQL database Operations Starter Tutorial, and A summary of common PHP database operation techniques

I hope this article is helpful to you in PHP programming.

Articles you may be interested in:

    • Php+ajax No Refresh Page instance detailed
    • Php+ajax Implement no Refresh paging
    • Detailed Php+ajax No Refresh paging implementation method
    • Php+ajax implementation of no-refresh paging method
    • Ajax implementation without refresh paging (PHP)
    • PHP Ajax No refresh paging, support ID location
    • Jquery+php Publishing content for no-refresh paging (Fckeditor)
    • PHP jquery implements news tag classification and no refresh paging
    • A brief analysis of Php+ajax examples
    • Php+jquery+ajax implementation of Jpaginate plugin for paging effect
    • PHP page number form paging function support static address and Ajax paging

http://www.bkjia.com/PHPjc/1119989.html www.bkjia.com true http://www.bkjia.com/PHPjc/1119989.html techarticle Php+ajax Implementation of a non-refresh page instance of the detailed (with the demo source download), Ajaxdemo This article describes the Php+ajax implementation of the method of no refresh paging. Share to everyone for your reference, as follows: ...

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