I am simulating push notifications using PHP the following way:
- A jQuery ajax call calls a script on the server.
- The script is being delayed using a for loop and a sleep after each iteration.
- If something happens - the loop is being breaked and the information returned to the jQuery.
- If the script runs for more than one minute - the script returns an empty value.
- When the jQuery receives an answer from the server it parses the information and starts the same procedure again.
That's a procedure, used by facebook and it works like a charm on their website. On my server I have the following problem: For example if the script is being delayed for 60 seconds and I click on another link on my website on the 30-th second we still have 30 seconds left to generate the output. So my webserver is waiting those 30 seconds and my click request is being processed after those seconds, making my website almost impossible to use. I have doublechecked facebook and I found that, when you click on a link the page is never refreshed and the requests keep flowing on the same page. The adressbar however changes. What is the way to achieve the same thing on my website? Is there a way to force my server to process more then one PHP request at a time or we have to do this using javascript only. What am I missing?
P.S as far as I know there is no way to change the adressbar using javascript.