Php 如何在yii中使用AjaxSubmitButtom

Php 如何在yii中使用AjaxSubmitButtom,php,yii,Php,Yii,这是我的ajaxsubmitbutton <?php echo CHtml::ajaxLink('Assign',CController::createUrl('StudentsGuardian/Create',array('$guardian_id'=>$id,'$student_id'=>'js:studentid'),array('dataType'=>'html', 'complete'=>'js:alert("hurray")'))); ?> 我已

这是我的
ajaxsubmitbutton

<?php echo CHtml::ajaxLink('Assign',CController::createUrl('StudentsGuardian/Create',array('$guardian_id'=>$id,'$student_id'=>'js:studentid'),array('dataType'=>'html', 'complete'=>'js:alert("hurray")'))); ?>
我已经放置了VarDumper来查看这些值,但当按下按钮只是渲染它所属的视图时,它从未显示bcz Ajaxbutton。它不起任何作用。
我是yii的新手,请帮助我并为我指出正确的道路。
更新:
下面是设置srudentId的javascript代码

<script type="text/javascript">

       var studentid;
        $("#dropdownId").change(function(){
          studentid= $('#dropdownId :selected').val();

        });

    </script>

var studentid;
$(“#dropdownId”).change(函数(){
studentid=$('#dropdownId:selected').val();
});

当更改droplist时,将设置此studentid。

这将永远不会起作用,因为未设置studentid, 而且它并不打算这样使用,它在页面加载时总是空的,所以总是空的


另外,ajaxSubmitButton通过我认为GET方法发送相关表单,您需要从GET获取参数,将数据类型方法更改为POST类型

<?php echo CHtml::ajaxLink('Assign',
    CController::createUrl('StudentsGuardian/Create'),
    array('type' => 'POST',
        'data' => array('guardian_id' => $id, 'student_id'=> 'js:studentid'),
        'complete' => 'js:alert("hurray")'
    )
); ?>

事实上,我不需要在页面加载值。当dropDownList更改时,会调用Javascript,然后设置其值。第一个“$student\u id”=>“js:studentid”,第二个“actionCreate($guardian\u id,$student\u id)”
<?php echo CHtml::ajaxLink('Assign',
    CController::createUrl('StudentsGuardian/Create'),
    array('type' => 'POST',
        'data' => array('guardian_id' => $id, 'student_id'=> 'js:studentid'),
        'complete' => 'js:alert("hurray")'
    )
); ?>
public function actionCreate($guardian_id, $student_id)
{
    $guardian_id = isset($_POST['guardian_id'])? $_POST['guardian_id'] : $guardian_id;
    $student_id = isset($_POST['student_id'])? $_POST['student_id'] : $student_id;

    CVarDumper::Dump($guardian_id,100,true);
    CVarDumper::Dump($student_id,100,true);
    die();
    $model=new StudentsGuardian;

    $model->guardian_id = $guardian_id;
    $model->student_id = $student_id;
    // Uncomment the following line if AJAX validation is needed
    // $this->performAjaxValidation($model);

}