<p>Of course I am aware of Ajax, but the problem with Ajax is that the browser should poll the server frequently to find whether there is new data. This increases server load.</p>

<p>Is there any better method (even using Ajax) other than polling the server frequently?</p>

[{'answer_id': 20004, 'author': 'Greg Hurlman', 'author_id': 35, 'author_profile': 'https://Stackoverflow.com/users/35', 'pm_score': 7, 'selected': True, 'text': '<p>Yes, what you\'re looking for is COMET <a href="http://en.wikipedia.org/wiki/Comet_(programming)" rel="noreferrer">http://en.wikipedia.org/wiki/Comet_(programming)</a>.  Other good Google terms to search for are AJAX-push and reverse-ajax.</p>\n'}, {'answer_id': 20011, 'author': 'Dan Herbert', 'author_id': 392, 'author_profile': 'https://Stackoverflow.com/users/392', 'pm_score': 3, 'selected': False, 'text': '<p>Look into Comet (a spoof on the fact that Ajax is a cleaning agent and so is Comet) which is basically "reverse Ajax." Be aware that this requires a long-lived server connection for each user to receive notifications so be aware of the performance implications when writing your app.</p>\n\n<p><a href="http://en.wikipedia.org/wiki/Comet_(programming)" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Comet_(programming)</a></p>\n'}, {'answer_id': 20014, 'author': 'sparkes', 'author_id': 269, 'author_profile': 'https://Stackoverflow.com/users/269', 'pm_score': 1, 'selected': False, 'text': "<p>Once a connection is opened to the server it can be kept open and the server can Push content a long while ago I did with using <code>multipart/x-mixed-replace</code> but this didn't work in IE. </p>\n\n<p>I think you can do clever stuff with polling that makes it work more like push by not sending content unchanged headers but leaving the connection open but I've never done this. </p>\n"}, {'answer_id': 20015, 'author': 'Kibbee', 'author_id': 1862, 'author_profile': 'https://Stackoverflow.com/users/1862', 'pm_score': 2, 'selected': False, 'text': '<p>There are other methods.  Not sure if they are "better" in your situation.  You could have a Java applet that connects to the server on page load and waits for stuff to be sent by the server.  It would be a quite a bit slower on start-up, but would allow the browser to receive data from the server on an infrequent basis, without polling.</p>\n'}, {'answer_id': 20022, 'author': 'Ryan Ahearn', 'author_id': 75, 'author_profile': 'https://Stackoverflow.com/users/75', 'pm_score': 0, 'selected': False, 'text': '<p>You can also look into <a href="http://www.pushlets.com/" rel="nofollow noreferrer">Java Pushlets</a> if you are using jsp pages.</p>\n'}, {'answer_id': 20024, 'author': 'Markus Olsson', 'author_id': 2114, 'author_profile': 'https://Stackoverflow.com/users/2114', 'pm_score': 2, 'selected': False, 'text': '<p>It\'s possible to achive what you\'re aiming at through the use of persistent http connections.</p>\n\n<p>Check out the <a href="http://en.wikipedia.org/wiki/Comet_%28programming%29" rel="nofollow noreferrer">Comet article</a> over at wikipedia, that\'s a good place to start.</p>\n\n<p>You\'re not providing much info but if you\'re looking at building some kind of event-driven site (a\'la digg spy) or something along the lines of that you\'ll probably be looking at implementing a hidden IFRAME that connects to a url where the connection never closes and then you\'ll push script-tags from the server to the client in order to perform the updates.</p>\n'}, {'answer_id': 20312, 'author': 'Pablo Alsina', 'author_id': 2295, 'author_profile': 'https://Stackoverflow.com/users/2295', 'pm_score': 3, 'selected': False, 'text': '<p>I would strongly suggest to invest some time on Comet, but I dont know an actual implementation or library you could use.</p>\n\n<p>For an sort of "callcenter control panel" of a web app that involved updating agent and call-queue status for a live Callcenter we developed an in-house solution that works, but is far away from a library you could use.</p>\n\n<p>What we did was to implement a small service on the server that talks to the phone-system, waits for new events and maintains a photograph of the situation. This service provides a small webserver.</p>\n\n<p>Our web-clients connects over HTTP to this webserver and ask for the last photo (coded in XML), displays it and then goes again, asking for the new photo. The webserver at this point can:</p>\n\n<ul>\n<li>Return the new photo, if there is one</li>\n<li>Block the client for some seconds (30 in our setup) waiting for some event to ocurr and change the photograph. If no event was generated at that point, it returns the same photo, only to allow the connection to stay alive and not timeout the client.</li>\n</ul>\n\n<p>This way, when clients polls, it get a response in 0 to 30 seconds max. If a new event was already generated it gets it immediately), otherwise it blocks until new event is generated.</p>\n\n<p>It\'s basically polling, but it somewhat smart polling to not overheat the webserver. If Comet is not your answer, I\'m sure this could be implemented using the same idea but using more extensively AJAX or coding in JSON for better results. This was designed pre-AJAX era, so there are lots of room for improvement.</p>\n\n<p>If someone can provide a actual lightweight implementation of this, great!</p>\n'}, {'answer_id': 41145, 'author': 'Mike Schall', 'author_id': 4231, 'author_profile': 'https://Stackoverflow.com/users/4231', 'pm_score': 2, 'selected': False, 'text': '<p>Comet was actually coined by Alex Russell from Dojo Toolkit ( <a href="http://www.dojotoolkit.org" rel="nofollow noreferrer">http://www.dojotoolkit.org</a> ).  Here is a link to more infomration <a href="http://cometdproject.dojotoolkit.org/" rel="nofollow noreferrer">http://cometdproject.dojotoolkit.org/</a></p>\n'}, {'answer_id': 97038, 'author': 'Gilles', 'author_id': 10024, 'author_profile': 'https://Stackoverflow.com/users/10024', 'pm_score': 3, 'selected': False, 'text': '<p>An interesting alternative to Comet is to use sockets in Flash. </p>\n'}, {'answer_id': 304768, 'author': 'Thomas Hansen', 'author_id': 29746, 'author_profile': 'https://Stackoverflow.com/users/29746', 'pm_score': 1, 'selected': False, 'text': '<p>You could try out our <a href="http://ra-ajax.org/samples/Ajax-Comet.aspx" rel="nofollow noreferrer">Comet Component</a> - though it\'s <em>extremely</em> experimental...!</p>\n'}, {'answer_id': 305889, 'author': 'Buzzy', 'author_id': 38070, 'author_profile': 'https://Stackoverflow.com/users/38070', 'pm_score': 2, 'selected': False, 'text': '<p>You can use a Flash/Flex application on the client with BlazeDS or LiveCycle on the server side. Data can be pushed to the client using an RTMP connection. Be aware that RTMP uses a non standard port. But you can easily fall back to polling if the port is blocked.</p>\n'}, {'answer_id': 616038, 'author': 'BigJump', 'author_id': 8542, 'author_profile': 'https://Stackoverflow.com/users/8542', 'pm_score': 2, 'selected': False, 'text': '<p>Might be worth checking out <a href="http://meteorserver.org/" rel="nofollow noreferrer">Meteor Server</a> which is a web server designed for COMET.  Nice <a href="http://meteorserver.org/demo/" rel="nofollow noreferrer">demo</a> and it also is used by <a href="http://www.twitterfall.com" rel="nofollow noreferrer">twitterfall</a>.</p>\n'}, {'answer_id': 661450, 'author': 'Evan', 'author_id': 6277, 'author_profile': 'https://Stackoverflow.com/users/6277', 'pm_score': 0, 'selected': False, 'text': '<p>Might want to look at <a href="http://www.reversehttp.net/" rel="nofollow noreferrer">ReverseHTTP</a> also.</p>\n'}, {'answer_id': 1478289, 'author': 'Nosrama', 'author_id': 147386, 'author_profile': 'https://Stackoverflow.com/users/147386', 'pm_score': 5, 'selected': False, 'text': '<p>Yes, it\'s called <strong>Reverse Ajax</strong> or <strong>Comet</strong>.  Comet is basically an umbrella term for different ways of opening long-lived HTTP requests in order to push data in real-time to a web browser.  I\'d recommend <a href="http://www.stream-hub.com/" rel="nofollow noreferrer">StreamHub Push Server</a>, they have some cool demos and it\'s much easier to get started with than any of the other servers.  Check out the <a href="http://streamhub.blogspot.com/2009/07/getting-started-with-streamhub-and.html" rel="nofollow noreferrer">Getting Started with Comet and StreamHub Tutorial</a> for a quick intro.  You can use the Community Edition which is available to download for free but is limited to 20 concurrent users.  The commercial version is well worth it for the support alone plus you get SSL and Desktop .NET &amp; Java client adapters.  Help is available via the <a href="http://groups.google.co.uk/group/streamhub-comet-server-community" rel="nofollow noreferrer">Google Group</a>, there\'s a good bunch of tutorials on the net and there\'s a <a href="http://code.google.com/p/gwt-comet-streamhub/" rel="nofollow noreferrer">GWT Comet adapter</a> too.</p>\n'}, {'answer_id': 1809504, 'author': 'Jerod Venema', 'author_id': 25330, 'author_profile': 'https://Stackoverflow.com/users/25330', 'pm_score': 3, 'selected': False, 'text': '<p>Comet is definitely what you want. Depending on your language/framework requirements, there are different server libraries available. For example, <a href="http://www.frozenmountain.com/websync" rel="noreferrer">WebSync is an IIS-integrated comet server for ASP.NET/C#/IIS developers</a>, and there are a bunch of other standalone servers as well if you need tighter integration with other languages.</p>\n'}, {'answer_id': 15598348, 'author': 'arun peddakotla', 'author_id': 2204453, 'author_profile': 'https://Stackoverflow.com/users/2204453', 'pm_score': 1, 'selected': False, 'text': '<p>please check this library <a href="https://github.com/SignalR/SignalR" rel="nofollow">https://github.com/SignalR/SignalR</a> to know how to push data to clients dynamically as it becomes available</p>\n'}, {'answer_id': 19458245, 'author': 'pafinde', 'author_id': 1033410, 'author_profile': 'https://Stackoverflow.com/users/1033410', 'pm_score': 5, 'selected': False, 'text': '<p>Nowadays you should use WebSockets.\nThis is 2011 standard that allows to initiate connections with HTTP and then upgrade them to two-directional client-server message-based communication.</p>\n\n<p>You can easily initiate the connection from javascript:</p>\n\n<pre><code>var ws = new WebSocket("ws://your.domain.com/somePathIfYouNeed?args=any");\nws.onmessage = function (evt) \n{\n  var message = evt.data;\n  //decode message (with JSON or something) and do the needed\n};\n</code></pre>\n\n<p>The sever-side handling depend on your tenchnology stack.</p>\n'}, {'answer_id': 28970230, 'author': 'נשמה קשוחה', 'author_id': 579078, 'author_profile': 'https://Stackoverflow.com/users/579078', 'pm_score': 3, 'selected': False, 'text': '<p>Yet another, standard, way is <a href="https://developer.mozilla.org/en-US/docs/Server-sent_events" rel="noreferrer">SSE (Server-Sent Events, also known as EventSource</a>, after the JavaScript object).</p>\n'}]
['https://Stackoverflow.com/questions/19995', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/184/']