1

There are interactive sites (for example this :)) which can notice events without refreshing anything. For example, when I get an answer, a red circle will appear up there. I understand that it can be done with sending ajax requests, say one about every 5 second - but it then would kill servers. Then how should a server send to clients that something changed?

John Smith
  • 6,129
  • 12
  • 68
  • 123
  • 1
    possible duplicate of [AJAX Polling Frequency - To long poll or not to long poll?](http://stackoverflow.com/questions/3842063/ajax-polling-frequency-to-long-poll-or-not-to-long-poll) – JJJ Jun 01 '12 at 07:41

2 Answers2

2

Solutions like socket.io implement different ways to keep the client connected, including:

  • HTML5 Websockets (New, pretty good, but not supported by older browsers)
  • Flash plugin (Requires flash plugin, no mobile support)
  • Long polling (Killer for traditional webservices)
TJHeuvel
  • 12,403
  • 4
  • 37
  • 46
1

You can open an XHR that stays alive until the server has a state change to send the response.

This is known as long polling.

alex
  • 479,566
  • 201
  • 878
  • 984