控制器
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;
}
<!--操作成功 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>
效果圖