I have a server and many clients (around 50 clients) who connect to that server based on a web application, which is of course based on HTTP protocol, which in turn uses TCP/IP (correct me if I'm wrong, cause I'm not really good at networking).

The problem is that, I should develop an alert mechanism, in which, when somebody submits a form with dangerous values, the manager (who is also connected via the same web application) should receive an alert pop-up on his screen, almost real-time (instantly).

However, since the HTTP protocol is stateless, I' a little puzzled here. I don't know how I can implement this.

One of the solutions could be to use JavaScript alongside setInterval() function to pull data each second from server. But this seems a little dirty to me and unprofessional.

Do you guys have any idea of implementing another solution?


2 Answers 2


You should use some kind of ajax push (see Comet) to notify the clients. It can eliminate the need for polling, you basically keep an established connection open which can be used to notify the browser of ocurring events. However, this does not work with all browsers. You fall back to "long polling" in such cases.


This is a good use case for WebSockets were created for. If you don't need compatibility with older browsers you might want to use this instead of polling (and possibly fall back to polling).

Another solution is to use server-sent events.

I'm not sure how stable the spec/implementations are these days (it was not very stable not so long ago). It seems the latest spec is implemented in Firefox 6 and Chromium 14.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.