javascript - Get Refesh Data From The Server -


how can latest or fresh data server (if in server happened new event (for example there 2 users x,y , x send messages y , y message without refreshing page ) )? don't want use setinterval because repeats message again , again. there technique can use ? heard ajax technique need send request server want when happen event in server , webpage without refreshing..

the first technique long polling, sends request server , waits until server sends something, example new message. must re-send requests server each time new message or request time out. technique uses ajax. long polling php example - how implement basic "long polling"?

the second web sockets, https://en.wikipedia.org/wiki/websocket

this stackoverflow question deals implementation of websocket.

socket.io has demo of chat application.


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -