dongyange1101 2013-12-06 11:54
浏览 93
已采纳

如何使用yii调用重定向到另一个控制器操作视图?

How can i redirect to another controller action view using yii ajax call ? here is my ajax function

function test(id) 
{  
    $.ajax({
       type: "POST",      
       data: "id="+id,
       url: "<?php echo Yii::app()->createUrl('controller/action'); ?>",
       success: function (msg){ }   
    });  
}

From my action i want to call a view in another window.

  public function action
  {
     //doing some php code here to create $dataProvider
     $this->render('view',array('dataProvider'=>$dataProvider),array('target'=>'_blank'));
  }

is this possible ? please help

  • 写回答

2条回答 默认 最新

  • douyanjing8287 2013-12-26 07:07
    关注

    At last I got the answer for my question..

    I'm using CHtml::link instead of using ajax.

    view :

    CHtml::link(
            CHtml::encode('id'), 
            array('controller/action','id'=>'id'),
            array('href'=>'/index.php/controller/action',
            'target'=>'_blank')
         )
    

    Controller :

    public function action
      {
         //doing some php code here to create $dataProvider  
         $this->render('view',array('dataProvider'=>$dataProvider));
      }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 宇视监控服务器无法登录
  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥15 DruidDataSource一直closing
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据