我在 jquerymobile 对话框中有一个表单,我通过 jQuery Ajax 提交该表单。
目前我的问题是,提交表单后,会在原始对话框之上再次打开相同的对话框。
以便我的网址在提交之前读取:
url/index.php#&ui-state=dialog
提交后:
url/index.php#&ui-state=dialog#&ui-state=dialog&ui-state=dialog
有人遇到过类似的事情吗?
[编辑添加的代码示例]
$(function(){
$("#form").submit(function(e){
e.preventDefault();
var dataString = $("#form").serialize();
errorInput = $("input[name=valOne]#valOne").val();
$.ajax({
type: "GET",
url: "formHandler.php",
data: dataString,
dataType: "text",
success: function(data){
if(data.toLowerCase().indexOf("error") >= 0){
alert(data);
$(".ui-dialog").dialog("close");
$("#valOne").val(errorInput); //the reentering info so user doesn't have to
}else{
$(".ui-dialog").dialog("close");
location.href="index.php";
}
},
error:function (xhr, ajaxOptions, thrownError){
alert(thrownError);
}
});
});
});
最佳答案
- 您可以使用此 submit 在表单上设置自己的处理程序
- 为页面和对话框窗口使用两种形式。
关于ajax - 通过对话框提交的表单再次打开对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13222284/