I have seen many websites (facebook or stack overflow for instance) that will update certain features as new data is generated (new answer on a post for example).
Lets say that there is a new post added to a blog and someone is in the blog in that moment looking at it, the idea is to automatically add the new post to the blog without refreshing or having the user to do any action.
I have thought of executing an AJAX call every 5 seconds or so, but that will make too many requests to the server, and I saw that the websites I mentioned (which renew content) don't make any new requests.
I am really out of ideas of how to achieve this. Is this possible with PHP and AJAX? I've heard of websockets too. Any ideas?
great question. There's a few solutions..
There's been a relatively new solution to this call websockets. It's in the HTML5 standard and there's a lot of libraries for it on other languages too.
And for php: http://socketo.me/
Visit this link for more info: http://www.html5rocks.com/en/tutorials/websockets/basics/