How does Twitter shows data - How does the logic behind works?
Hello,
Today I wanted to show users comments on my website in a twitter way, no refresh, new comments showing up on all the user browsers.
My first question is, what kind of logic would you use to show comments:
1)Use Jquery in a way that it detects when the user is not touching the screen or using the keyboard and send an ajax call after a given amount of time(let's say every 10 seconds when the user does not touch his screen or keyboard).
2)Check time of comments insertion in the database and add all the new comments that have passed a given amount of time without being published?
3)Continuous ajax calls every 5 or 10 seconds.
4)Use some kind of cron job that check once the database and output on all the user browsers the new comments(rather than having each user checking the new comments).
I am wondering is Jquery has a magic trick(with php) to solve this issue without using a framework.
Thank you.
Ben