How to auto refresh page without blink


I want to call a php function in my controller and display a message on the page if the function returns true.

currently I am using javascript to just refresh the page, but this is causing the page to blink every 30 seconds.

I am using CListView to display the data if the function returns true.

how can I do this in Yii?


<script src=""></script>


var refreshId = setInterval(function()



}, 10000);


<?php $this->widget('zii.widgets.CListView', array(



)); ?>

Above code is not refreshing the list

I think this is the function you need to use




In controller or in the view?

You should create a little component: /protected/components/YourComponent.php with a static method:

class YourComponent {

        public static function yourMethod () {

                return true;



and call it in your controller:

if(YourComponent::yourMethod() == true) {

       // do something



I got this working using


 $this->widget('zii.widgets.CListView', array(




	'afterAjaxUpdate'=>'function(id,options){document.all.sound.src = "../notify.wav"; }',


I am having trouble calling a javascript function, not working.