views:

136

answers:

2

Twitter's Streaming API seems to provide a way to receive realtime tweets without constantly polling for new data. Would it be possible to make use of this API using jQuery (or maybe falling back to pure JS)?

As far as I can tell, there's no built-in way for jQuery to stream an HTTP request with JSON. Is that correct, or did I miss something? If this ability isn't built-in, has anyone already tackled this problem with a plugin or example?

Update: From what I can gather, HTML 5's support for WebSockets would likely be the best approach to achieve this. Unfortunately that means mainstream compatibility is still at least a few years out. As far as I know, these browser versions currently support WebSockets in some fashion:

  • WebKit 5 (Safari/Chrome)
  • Firefox 4
  • IE9 (Eventually)
A: 

This page might be of interest:

http://ajaxpatterns.org/HTTP_Streaming#Refactoring_Illustration

passcod
+3  A: 

HTML5 WebSockets would probably be the best choice.

It is possible to use WebSockets for modern browsers and Flash fallback for unsupported browsers.

This one supports alle browsers: http://jwebsocket.org/index.htm?page=browsers.htm

You can also try this on, but not tested on IE6: http://github.com/gimite/web-socket-js

mofle