How to pass the variable values from one view to a

2019-08-13 10:38发布

问题:

one my view sending the database id values to controller using ajax link how to send those values to another view from controller. I have tried using ajax link but it is showing undefind index 'id' . here is my ajax link.

<?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' ),

         )
        );?>

my controller

   <?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();
}?>