I have a form in a jquerymobile dialog box that I am submitting via jQuery Ajax.
我在jquerymobile对话框中有一个表单,我通过jQuery Ajax提交。
Currently my problem is that once the form is submitted the same dialog box is opened again on top of the original dialogbox.
目前我的问题是,一旦提交表单,将在原始对话框的顶部再次打开相同的对话框。
So that my url reads before submission:
所以我的网址在提交前阅读:
url/index.php#&ui-state=dialog
and then after submission:
提交后:
url/index.php#&ui-state=dialog#&ui-state=dialog&ui-state=dialog
Has anyone ever encountered something like this before?
有没有人曾经遇到过这样的事情?
[edit added code example]
[编辑补充代码示例]
$(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);
}
});
});
});
0
您可以使用此提交在表单上设置自己的处理程序
对页面和对话框窗口使用两种形式。
0
Have you tried using $.mobile.changePage("url here") instead of location.href? More details here http://jquerymobile.com/test/docs/api/methods.html
您是否尝试过使用$ .mobile.changePage(“url here”)而不是location.href?更多详情请访问http://jquerymobile.com/test/docs/api/methods.html
0
Would it not be easier to just refresh the page with JS instead of loading it again? It might be calling the dialog functions twice.
用JS刷新页面而不是再次加载它会不容易?它可能是两次调用对话框函数。
0
I had similar problem with forms. I decided to use <div data-role="fieldcontain">
instead. Now it works good with no "refresh effect". In this case you shouldmake your own message instead of .serialize.
我的表格有类似的问题。我决定改用
本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2012/11/04/bdd0b702c3d64350f3eb5b4124af6c18.html。