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