The model adopted by web servers before HTML 5 is one-way requests, which in practice means that the server can never send a request to the client, just the opposite. The server can only send data to a client in response to a request.
Current Strategy: Polling
The tactic you are using is called polling , which is to ask the timeserver in if there is "something new". This tactic is the only one possible when one side can not initiate a request.
Using HTML5: Websockets
HTML 5 introduced websockets . This technology allows the client to open a two-way with the server, and therefore receive or send data at any time.
The latest standardization of websockets is rfc6455 and is supported by the following browsers:
- Internet Explorer 10 +
- Mozilla Firefox 4 +
- Safari 5 +
- Google Chrome 4 +
- Opera 11 +
If it is possible for your application to limit itself to these browsers, you can use websockets.
Using JAVA
It is also possible to use a Java applet to do bidirectional communication. This page shows a small example, with source code . The method of operation is similar to websockets - A connection to the part of the web request is opened with the server.
Using flash
It may be possible to use flash as well. I'm not sure.