如何在网址中传递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>
答案 0 :(得分: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>