我的一个视图使用ajax链接将数据库id值发送到控制器如何将这些值从控制器发送到另一个视图。我尝试过使用ajax链接但它显示的是未读取索引'id'。这是我的ajax链接。
<?php echo CHtml::ajaxLink(
"Link Text",
Yii::app()->createUrl( 'site/videotutorials1' ),
array( // ajaxOptions
'type' => 'POST',
'beforeSend' => "function( request )
{
// Set up any pre-sending stuff like initializing progress indicators
}",
'success' => "function( data )
{
// handle return data
// alert( data );
window.location='http://localhost/VNR/index.php?r=site/videotutorials/';
}",
'data' => array( 'val1' => '1', 'val2' => '2' )
),
array( //htmlOptions
'href' => Yii::app()->createUrl( 'site/videotutorials1' ),
)
);?>
我的控制器
<?php public function actionVideoTutorials1() {
// renders the view file 'protected/views/site/index.php'
//echo $_POST['id'];
/* if(isset($_POST['id']))
$polygon = $_POST['id'];
else
$polygon = NULL;
echo CJSON::encode(array('polygon'=>$polygon));
//echo 'Success';
die();
$this->render('videotutorials1', array('id' => $polygon));*/
echo $val1 = $_POST['val1'];
echo $val2 = $_POST['val2'];
//
// Perform processing
//
//
// echo the AJAX response
//
echo "some sort of response";
$this->render('videotutorials1', array('id' => $myUrl));
//Yii::app()->end();
}?>