PHP implementation of Ajax long polling _ PHP Tutorial

Source: Internet
Author: User
PHP implements Ajax long polling. PHP implements the traditional Ajax round-robin method for long-polling AJAX. the client queries the latest data on the server at a user-defined interval. This method of pulling data requires PHP to implement Ajax long polling in a short time.

In the traditional AJAX round-robin mode, the customer service end queries the latest data on the server at a user-defined interval. This data pulling method requires a short time interval to ensure data accuracy. However, the customer service end sends multiple requests to the server within a short time interval.

Reverse AJAX is called long polling or COMET. The server and the client need to maintain a long request so that the server can return a message to the client when there is data.

Here, we use AJAX to request the data. php page to obtain the 'success' value. The request time reaches 80 seconds. If 'success 'is not returned from the server during the 80 seconds, the connection remains established until data is returned or the value of 'success' is 0. The next request is continued after the connection is closed.

Index.html

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.