PHP asynchronous load data process sharing

Source: Internet
Author: User
No Refresh function We use a lot of, the following I would like to introduce to you an example, is to implement the PHP+AJAX implementation of non-flush scrolling loading data, the example is very simple everyone just follow the process to operate it can be OH.

1. First, we want to get the height of the browser viewable area page

2. Then, when scrolling the page, the thing to do is to calculate the total height of the page (when scrolling at the bottom, the page loads new data, so the total height of the page is dynamic), calculate the scrollbar position (the scrollbar position is also dynamic with the loading of the page height), and then construct a formula to calculate the relative proportions

3. When the scrollbar is near the bottom of the page, triggering the Ajax load, in this case we use the jquery Getjson method to send the request to the server result.php, the requested parameter is page, that is, the number of pages

4. If the request response returns JSON data successfully, parse the JSON data and append the data to the page Div#container, if no JSON data is returned, the data is all displayed

5. The complete jquery code is as follows


6.result.php

When scrolling to the bottom of the page, the front-end Ajax requests to result.php, the daemon will query the data table according to the requested number of pages: page, and the recordset in JSON format output returned to the front-end processing

7. Well, the introduction of this article to the end, go to see the effect of it.

Description

General asynchronous loading uses the Ajax calling method

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.