Using AJAX the best way in Yii


So, I have this page in my application where good amount of numbers are being displayed. All this data is being pulled from the database. It is like an analytics system wherein the database is updated through various events outside and the numbers get reflected in this app of mine. Currently, numbers do get updated when I refresh the browser of course. I want to make it work in a way that I just have to open this page once and all the numbers get updated (without refresh) automatically, as and when there are changes in the database.

So, user just has to keep the page open and whenever he comes back, it should show him the content based on the current data in the database. I’ve not worked with this kind of functionality before so I need a some guidance as to how to use Yii API the best possible way to achieve these results. Hoping for good guidance from experienced developers.

No inputs on this one yet? any links where I can check out some info on the same?

For my point of view, this is a setInterval (javascript) type of functionality that will update the data displayed on the screen based on the ajax calls and the content returned.

That is how I would do it though


Search Google for ‘jquery long polling’ :)


Haven’t actually tried this myself.

Here’s another idea:

Probably better. ;)

hey antonio, thanks for your thoughts on this. could you please share a link where i can learn more about the method you’ve explained?

thanks jacmoe, the stackoverflow one is interesting. i think i’ll try that one.