控制器
1、方法1
//执行操作
if(Product::model()->updateAll($set,$criteria)){
//成功跳转
$this->render('../index/success',array('message'=>'恭喜,产品审核成功'));
exit;
}else{
//失败跳转
$this->render('../index/error',array('message'=>'对不起,产品审核操作失败,请稍后再试!'));
exit;
}
2、 默认3秒后跳转到定义的第一个链接
$this->render('../index/success',array(
'message'=>'恭喜,宝贝信息发布成功',
'links'=>array(
array('浏览发布的产品','/company/product/update/id/'.$model->zp_id),
array('继续发布产品','/company/product/create/step/1'),
),
));
exit;
3、另一种js跳转方式,它会替代全部页面显示,没有布局文件,可用于ajax更新的时候错误跳转
if(!MemGroup::model()->exists($criteria)){
jsRedirect($url,'2','操作错误,选中项操作名不能为空','controllerActions');
exit;
}
视图页面:可以在视图views/index/下建一个success.php
<!--操作成功 start-->
<div class="change_done bd_db">
<p>
<span class="ico_big ico_done"></span>
<span class="fw_b fs_14"><?php echo isset($message)?$message:'操作成功' ?></span>
</p>
<p class="line_30">现在去,
<?php
foreach($links as $link){
echo CHtml::link($link[0],$link[1],array('class'=>'c_06c mr10'));
}
?>
</p>
<p class="c_666 ml40">该页将在 <span id='setouttime'>3</span>秒后自动跳转!</p>
</div>
<!--操作成功 end-->
<script language=javascript>
var int=self.setInterval("countdown()",1000);
function countdown(){
var t=document.getElementById("setouttime").innerHTML-1;
document.getElementById("setouttime").innerHTML=t;
if(t===0){
location='<?php echo $links[0][1]?>';
}
}
</script>
效果:(以上代码没有CSS文件,所以没有这些样式)