0
I have to make a system where the user sends a message and the one who receives it, sees the number 1 on the menu side, at the time the message is received. Like facebook, when you get a notification you’re number one on the globe side. I was wondering if anyone has any idea how to do this, I was thinking of doing it using the function setTimeOut
of jQuery and make it keep updating every 2 seconds to check something new relative to the user it received.
Question that can help with some websocket and push concepts: http://answall.com/questions/9067/%C3%89-poss%C3%Advel-fazer-comunica%C3%A7%C3%A3o-client-server-in-real-time-via-http
– Wakim
SetTimeout fix is not jQuery, but javascript native, you might consider using $.ajax to check for new messages. About the time 2 seconds I think it is a very short time, and can cause problems regarding server performance. Amazon for example performs its ajax updates every 20 seconds if I’m not mistaken.
– Hiago Souza
@Hiagosouza you consider the option to merge the function setTimeOut with $.ajax() good to do what I need?
– Alisson Acioli
Of course, in $.ajax you can declare dataType as script and send back a jquery function to change your DOM.
– Hiago Souza