Welcome to WebmasterWorld Guest from 34.207.152.62

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

How to push updates to your website in real time

     
2:56 am on Nov 18, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 10, 2008
posts: 1130
votes: 0


I'm curious as to how websites such as facebook or twitter can push updates to your page as you are viewing them. I understand php and ajax, I just don't know the concept behind how they sends those updates to the browser without user interaction. I'm just looking for a general explanation here. I can figure out the code, it's the concept I'm after. Not opposed to any good resources to read too. Thanks,
4:47 am on Nov 18, 2010 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member tangor is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Nov 29, 2005
posts:9037
votes: 752


In general there is a periodic refresh of the page, during which any new content will be displayed.
5:19 pm on Nov 19, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Mar 30, 2006
posts:1574
votes: 119


Updates to the page the user is viewing? Ajax combined with your server side scripting.

I just don't know the concept behind how they sends those updates to the browser without user interaction


Use javascript setinterval to solve it.

  • Set your page to load content via ajax from your server and display it, be it onload or via button-link (make it a function, so you can call it diff ways)
  • Once you have that working you can automate it setting an interval calling that function, this way the user will not need to hit refresh or to reload the page.


That's easy, just getting the data and display it. The tricky part is saving time, work and bandwith. You could set your app to only check for items-news and Ids... so you can check it against the ones you already have on your page, thus, only calling the content you don't have. This is better than getting the whole content again and again, just push it (add it) to the one you have on your page.

good luck
9:18 pm on Dec 1, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 10, 2008
posts: 1130
votes: 0


I guess I was unaware they refreshed the page. I thought that they were somehow pushing data to it in real time. I have written things that refresh every so often to update data.
9:18 pm on Dec 1, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 10, 2008
posts: 1130
votes: 0


I guess I was unaware they refreshed the page. I thought that they were somehow pushing data to it in real time. I have written things that refresh every so often to update data. Thanks for your insight.
11:56 pm on Dec 1, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2006
posts: 3123
votes: 0


I guess I was unaware they refreshed the page.


I think it's confusing to say 'refreshed the page' here, since I believe that is what you are trying to avoid here?

As mentioned by explorador, you can use timer events - setInterval() and setTimeout() - to initiate XMLHttpRequests (AJAX) once the page has loaded rather than directly on a user triggered event.
8:09 am on Dec 3, 2010 (gmt 0)

Full Member

10+ Year Member

joined:June 21, 2007
posts: 316
votes: 0


I think I mentioned this in another post, but there's also the possibility of using something like a comet server with ajax push technology ( I only know of ape project, not used it myself though, I'm sure there are others) or other techniques such as long polling and utilising hidden iframes. Unfortunately finding a decent example using these is proving to be a stumbling block
10:17 am on Dec 3, 2010 (gmt 0)

Junior Member from IN 

10+ Year Member

joined:Nov 3, 2002
posts: 91
votes: 0


Yes all the above techniques are valid. To learn more about the comet

[ape-project.org...]
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members