Appear update equal to facebook, on time

Asked

Viewed 627 times

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.

  • 2

    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

  • 1

    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.

  • @Hiagosouza you consider the option to merge the function setTimeOut with $.ajax() good to do what I need?

  • Of course, in $.ajax you can declare dataType as script and send back a jquery function to change your DOM.

2 answers

1

  • I gave a preview and looked for examples, but most talk about chat or something that has to click to show in real-time, only the examples shows the person who sent receiving in real-time and I needed that one person sends and another receives in real-time, same as facebook.

-3

  • Know something with jQuery/Javascript ?!

  • Sorry but you read the question?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.