What I need to achieve is making a web site to automatically change when a database table was updated.
Here you can see exactly what I mean:
http://youtu.be/Lwfv65Naa78
In the above demo you can observe that the web site it’s changing in real time when other user interact with the site trough the iPhone app.
I would like to know if it’s possible to make this using php and jquery, and of course how to get starting.
Thanks!
Faye, cometd, long polling, Bayeux, WebSockets are all useful search terms.
Basically your code will listen on a channel which looks like a url like: ‘/posts’ this is managed by the server with the same channel. Your controller code pushes updates, probably json to the channel, and your javascript that is listening to the channel uses the json to update the page.
Imagine an ajax request on the client that never finishes loading, and on the server you keep writing to the page the ajax request is downloading. Kind of like a “Socket”. If you are hellbent on a roll your own, i’d look into how to stream with ajax, and how to flush buffers on php.