我有使用ajax调用对话框关闭功能的这个问题。Ajax调用yii对话框关闭功能失败
这是我的Ajax调用函数:
function samplefunction(var1,var2){
$.ajax({
url: "controllerFunction?var1="+var1+"&var2="+var2,
type: 'POST',
dataType: 'json',
success: function(data)
{
$("#htmlmessage").html(data.message);
$("#htmlmsgdialog").dialog("open");
}
});
}
这里的对话框代码:
<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog',array(
'id'=>'sampledialogboxname',
'options'=>array(
'title'=>'Sample Dialog Box I',
'autoOpen'=>false,
'modal'=>true,
'resizable'=>false,
'draggable'=>false,
'position'=>array("middle",30),
'width'=>650,
'show'=>'fade',
'hide'=>'fade',
'open' => 'js:function(event,ui){
//some code here
}',
**'close' => 'js:function(event,ui){
samplefunction("samplestring1","samplestring2");
window.location.href = "'.$sampleurl.'";
}',**
'buttons' => array
(
array('id' => 'firstback','text'=>'BACK',
'click'=> 'js:function(){
samplefunction("samplestring1","samplestring2");
$(this).dialog("close");
window.location.href = "'.$sampleurl.'";
}'),
array('id' => 'secondback','text'=>'BACK','click'=> 'js:function(){
//some code here
}'),
array('id' => 'thirdback','text'=>'BACK','click'=> 'js:function(){
//some code here
}'),
array('id' => 'fourthback','text'=>'BACK','click'=> 'js:function(){
//some code here
}'),
array('id' => 'firstnext','text'=>'NEXT','click'=> 'js:function(){
//some code here
}'),
array('id' => 'secondnext','text'=>'NEXT','click'=> 'js:function(){
//some code here
}'),
array('id' => 'thirdnext','text'=>'NEXT','click'=> 'js:function(){
//some code here
}'),
array('id' => 'save','text'=>'SAVE','click'=> 'js:function(){
//some code here
}')
),
),
));?>
这里的控制器功能:
public function actionControllerFunction($var1, $var2)
{
var_dump($var1, $var2);
//Do Some Code here
$result['showdialog'] = true;
$result['message'] = "Sample Msg.";
echo json_encode($result);
exit;
}
我的问题是,AJAX调用总是失败甚至在我进入控制器功能之前。 我检查了我的参数,它也有适当的字符串传递。 我非常需要帮助。任何意见,这将有助于我对此表示高度赞赏。 谢谢。 (^ __ ^)
你的意思是Ajax调用没有发生? ajax呼叫的状态是什么? –
我没有看到任何返回的状态,只是网址在萤火虫中处于红色状态,并且没有任何操作。 (_。_) –
您检查萤火虫请求的响应 –