Javascript opened connection
I wondered how pages like facebook.com works. When I look at firebug output in firefox to xhttprequests
, there are many of closed connections, but there are also many opened connections. Ther开发者_JS百科e must be a better way then asking server "are there any new messages" every second, but in other way, http header contains length of html body in bytes and browser downloads content in this exact length, so request couldn't work that way.
Have a look at this Comet
and you can find some examples here, How do I implement basic "Long Polling"?
Or the new way to do things Websockets ( and now with flash fallback )
You can create live-ajax connection and you don't need to create new and new connections
精彩评论