ajax - 通过对话框提交的表单再次打开对话框

标签 ajax jquery jquery-mobile

我在 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);
            }
        });
    });
});

最佳答案

  1. 您可以使用此 submit 在表单上设置自己的处理程序
  2. 为页面和对话框窗口使用两种形式。

关于ajax - 通过对话框提交的表单再次打开对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13222284/

相关文章:

javascript - 在危险的垂直滑动器中需要垂直滚动条

ajax - 如何在 RadGrid 的 FormTemplate 中设置 Telerik RadComboBox 的 SelectedValue 属性

javascript - 保留旧图像,直到新图像准备好更新

javascript - "Listening"到来自 Capybara/Selenium 的 AJAX 调用 - Rails

javascript - 为什么 bootstrap 4 slider 工作不顺畅?

jquery - 415 在 ajax 调用 Spring mvc 中发送 json 对象时不支持的媒体类型

jquery-mobile - 如何完全禁用 jQuery Mobile 中的 Loader

javascript - 如何使用 jquery mobile 为两个连续的弹出窗口制作动画?

javascript - 在 PHP 中发布选项文本而不是值

javascript - ajax验证成功后才提交表单