php - AJAX chat without periodic refresh? -


i'm write ajax based chat. best way refresh chat box? know there few possibilitys best suited chat?

additional: possible reload unread text? if writes text isn't nessecarry refresh whole content.the new message enough. can done ajax , php? have no idea how done. thankfull tipp ... thanks!

the frequency of refresh , scope of content refresh independent. ajax, can ask server if new message arrived (based on timestamp), , append displayed content, don't have reload whole page.

as 'periodic refresh' thing: can go either short polling or long polling. think 'periodic refresh' may refer short polling. timer, e.g. in every second server polled javascript there new data displayed. if yes, sends it, otherwise replies message indicating there no new content.

whilst in long polling, server polled, , gives new content if has it. however, if there no new content, instead of giving immediate answer of 'no new content', keeps connection open, , answers when has send. can achieved in several different ways, , theoretically provides better response time, in practice, can result in timeout, or heavy reasource usage on server, if implemented in way.

you can see long polling example here: http://www.screenr.com/snh


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -