3

I do not know if my tile line is clear enough... My problem is: I have a JS application that needs to wait for an event on the server. At the moment it polls continuous the server data via XMLHttpRequest every second.

What I am thinking about is: Is it possible to make the call wait until for example a variable in PHP changes?

I hope that my question is clear enough.

Thanks!

Simon
  • 4,395
  • 8
  • 33
  • 50

1 Answers1

7

You're looking for long polling (colloquially known as Comet). There are many examples on SO and elsewhere.

Community
  • 1
  • 1
David Titarenco
  • 32,662
  • 13
  • 66
  • 111
  • 1
    Thank you very much! That was the right keyword and your last link will help me on developing my app. Thx! – Simon Feb 23 '11 at 07:37
  • 1
    Worth noting that php is very inefficient way to wait for an event. Also, can timeout after a minute or two depending on server configuration. Better to use node.js as a server if that is possible as it is event based, so does not waste processor whilst waiting for event. – Billy Moon Apr 10 '11 at 10:25