Php pop-up prompt

Source: Internet
Author: User
In php, how does one send a pop-up notification to the message receiver on a regular basis, similar to the pop-up reminder that the QQ mailbox receives a new email? is it easy to use: Notify () function ?, You cannot use sleep to pause php.
A pop-up reminder should be sent to the message recipient at regular intervals, similar to the pop-up reminder that the QQ mailbox receives new emails.

------ Solution --------------------
Very useful: http://download.csdn.net/detail/dmtnewtons/4219436
------ Solution --------------------
Isn't the setInterval () function in js?
------ Solution --------------------
No
Sleep suspends the execution of the current program and does not close the current http session.
In this way, each user will use a socket connection. System resources will soon be exhausted

It is worth noting that many people try to use ajax to simulate persistent connections. This is self-deception.
No information is displayed. XMLHttpRequest, as the core component of ajax, has the ability to reuse connections.
In this case, are you waiting on the server?


------ Solution --------------------
Ajax:
PHP code
# Put your prompt information on the backend and call var xmlHttp with Ajax; var timer = null; var timerRunning = false; var url; function createXMLHttpRequest () {if (window. XMLHttpRequest) {xmlHttp = new XMLHttpRequest ();} else if (window. activeXObject) {xmlHttp = new ActiveXObject ("Microsoft. XMLHTTP ") ;}} function statusStop () {if (timerRunning) {clearTimeout (timer) ;}timerrunning = true ;}/ * ----------------- interval query ------------------ -*/Function autoDeep () {createXMLHttpRequest (); url = "map. php? Refresh = "+ Math. random (); method = "GET"; xmlHttp. open (method, url, true); xmlHttp. onreadystatechange = null; xmlHttp. send (null); timerRunning = false; timer = setTimeout ('autodeep () ', 5000); // Set the time to 5 seconds.} function statusBegin () {statusStop (); autoDeep ();} statusBegin ();
------ Solution --------------------
Discussion
How can I control that only the person in charge will pop up a dialog box and other people will not pop up this box?

------ Solution --------------------
This user can be identified during background processing. if you are a user, you can directly add a judgment to him and push several js functions to the front-end. This is especially easier to implement with templates, there should be no problems

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.