setFlash redirect error

Hi all,

I have the following code, adopted from Yii CRUD:



<?php


public function actionDelete()


	{


		if(Yii::app()->request->isPostRequest)


		{


			// we only allow deletion via POST request


			$this->loadUser()->delete();


            


			$this->redirect(array('list'));


            Yii::app()->user->setFlash('succes', 'Gebruiker is verwijderd!');


		}


		else


			throw new CHttpException(500,'Invalid request. Please do not repeat this request again.');


	}


?>


Deleting works, but I don't get my flash message. I think the redirect is causing this.

Anyone knows a solution to this, or is this a bug?

TIA

First you set a flash message and then you redirect. Redirect sends a http header for redirects and stops script execution.

Well, I tried that either, but that doesn't work too.

I think its because the AJAX request that is made by clicking on the delete button of a CRUD table.

Strange…

Ajax request can mess with this stuff.

Is the function you showed called by an ajax request. If so, the redirect won't work anyway.