Reputation: 591
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
Upvotes: 1
Views: 8899
Reputation: 591
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));
}
Upvotes: 0
Reputation: 1310
You'll need to do the redirect in Javascript, for example in the success function. You can pass the URL as output from the PHP-action, then pick that up and set window.location.href.
Upvotes: 1