如何在ajax链接函数中传递js变量


how to pass js variable in the ajax link function

如何在URL中传递studentID ?因为它的js变量得到错误或它作为字符串传递。

<script>    
    function updateCallhistory(studentID)
    {  
        <?php   
            echo CHtml::ajax(array(
            'url'=> Yii::app()->createUrl("siteiq/UpdateStudentForm", array("ClassID" => $ClassID) ),           
            'data'=> "js:$(this).serialize()",
            'type'=>'post',
            'dataType'=>'json',
            'success'=>"function(data)
            {
            if (data.status == 'failure')
            {
                $('#dialogStudentForm div.divForForm').html(data.div);
                  // Here is the trick: on submit-> once again this function!
                $('#dialogStudentForm div.divForForm form').submit(updateCallhistory);
            }
            else
            {
                $('#dialogStudentForm div.divForForm').html(data.div);
                setTimeout('"$('#dialogStudentForm').dialog('close') '",1000);
            }
            } ",
        ))?>;
        return false;  
    }
    </script>

试试:

<script>    
    function updateCallhistory(studentID)
    {  
        var url = '<?php echo Yii::app()->createUrl("siteiq/UpdateStudentForm", array("ClassID" => $ClassID) ); ?>' + '&studentID='+studentID;
        <?php   
            echo CHtml::ajax(array(
            'url'=> 'js:url',           
            'data'=> "js:$(this).serialize()",
            'type'=>'post',
            'dataType'=>'json',
            'success'=>"function(data)
            {
            if (data.status == 'failure')
            {
                $('#dialogStudentForm div.divForForm').html(data.div);
                  // Here is the trick: on submit-> once again this function!
                $('#dialogStudentForm div.divForForm form').submit(updateCallhistory);
            }
            else
            {
                $('#dialogStudentForm div.divForForm').html(data.div);
                setTimeout('"$('#dialogStudentForm').dialog('close') '",1000);
            }
            } ",
        ))?>;
        return false;  
    }
    </script>