show flash message using ajax

Hi guys. The problem is: At Cgridview onclick event, i call my action using ajax:


type: "GET",

url: "index.php?r=protocolo/message",

dataType : "html",





Yii::app()->user->setFlash(‘success’, “Data1 saved!”);



View flash:

<?php if(Yii::app()->user->hasFlash(‘success’)):?>

&lt;div class=&quot;info&quot;&gt;

    &lt;?php echo Yii::app()-&gt;user-&gt;getFlash('success'); ?&gt;


<?php endif; ?>

But the result on firebug console is a plan text "Data1 saved".

What i need to do or what i do wrong to display flash messages using ajax.


where do you expect this message to appear? it looks like there is no target!

look for the success function

Take a look at the extension userflash it will do all the work for you.

If you don’t want to use this extension you can take a look at the code of the ‘EUserFlash::setAjaxMessage’ to see how it works.

Thank you so much!