1

如何在 URL 中传递学生 ID?由于它的 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>
4

1 回答 1

2

试试这个方法:

<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>
于 2012-12-24T08:24:13.923 回答