PHP Development Customer service System source code (persistent connection + polling + reverse Ajax)

Source: Internet
Author: User
Details:Http://www.phpyan.com/home/article/350.html Two ways to achieve this: One: IFRAME + server Push Technology Comet (reverse Ajax, that is, the server pushes data to the browser) Two: Ajax persistent connection + long polling Customer service using the first way: IFRAME + server Push Technology Ideas: 1: New comentbyiframe.php The file uses while (true) to connect to the server continuously. If new data is found in the while process. Use Ob_flush to push the Apache server. Apache then uses flush to push to the browser. 2: Create a new HTML page and insert an IFRAME. The IFRAME's SRC is comentbyiframe.php. and hide the IFRAME. The data obtained by comentbyiframe.php is output to a function in the parent window with JS. The function appends the information to the specified chat window 3: As long as the client receives data from the user. It shows as "xx says to you ...". Just click on the user name on the customer service side. Can send data to the user. The client takes the second approach: Ajax persistent connection + long polling Ajax Persistent Connection: After the document is loaded (or other time), use Ajax to request a PHP file The requested PHP file loops through while (true). Delay in giving Apache the purpose of returning data. Polling refers to the time when the server is requested. If the server does not have data. Then wait. When the server has data, it is returned to the client. This completes an HTTP request after the request and response. It's not over yet. The client receives the data and then goes to the server to have the data. This is polling It's like a beggar. If you don't give him money, he'll keep following you. After you give him the money. He is not satisfied, and came to you. Implementation ideas: After entering the client. If there is no user name. Use Setcookie to set a user name. Then persistent connection via Ajax. Continue to request data from the server (that is, customer service sent to the user's records)

Above the introduction of PHP Development Customer service System source (persistent connection + polling + reverse Ajax), including the content, I hope that the PHP tutorial interested in a friend helpful 。

  • Related Article

    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.