模态对话框在提交时无法正常工作 - 页面回发到自身

发布于 2024-12-02 17:07:37 字数 3068 浏览 1 评论 0原文

我之前问过这个问题,所以另一篇文章可能会被关闭。但是,我没有得到完整的正确答案,代码中似乎总是缺少一些东西。我需要提交一封电子邮件,获取一个模式框(带有确认消息),让模式在 3 秒后淡出,成功提交后,加载另一个页面。

基本上,模态框褪色太快了。我想放慢速度。有人建议我删除

</form><form> 

标签。尽管当我删除这些标签时模式确实会变慢,但现在提交后我没有看到“欢迎”页面。该页面似乎只是回发到自身而不是提交。我已经尝试了五天了,我不知道我做错了什么......我感谢所有答案。谢谢。

这是我的代码:

<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js">
</script>
<script src="http://recp.rm04.net//ui/library/formValidate.js" language="javascript">
    </script>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/ui-
  lightness/jquery-ui.css" rel="stylesheet" type="text/css">

<STYLE TYPE="text/css">
     BODY, .BODY, TD
     {  color: ;
        font-size: ;
        font-family: ;
        font-weight: ;
        text-decoration: ;
        font-style: ;
     }
     </STYLE>
</head>
<body vlink="" alink="" link="" bgcolor="">
<!--  demo -->
<div class="demo">
<div id="dialog" title="Basic dialog">
<p>Email submitted successfully.  Thank you for signing up!</p>
</div>
</div>

<!-- End demo -->
<br>
<br>
<table border="0" cellspacing="0" cellpadding="5">
<form name="form" method="post" action="http://links.mkt41.net/servlet/UserSignUp?
f=755449&postMethod=HTML&m=0&j=MAS2">
<tr>
<td valign="top"><span style="color:#CC0000">*</span></td><td valign="top"
align="left">Email:</td>
<td><input type="hidden" name="EMAIL_REQUIRED" value="T"><input type="hidden" 
name="EMAIL_DATATYPE" value="email"><input type="text" name="EMAIL" value="" 
maxlength="4000"></td>
</tr>
</form>
<form>
<tr>
<td align="center" colspan="3">
<div id="opener">
<input type="button" name="submit" value="Submit" onClick="f_validateForm()"></div>
<script src="js/modal_e-confirm.js" language="javascript"></script>
</td>
</tr>
</form>
</table>
<p>
</p>
<script>f_initializeForm();</script>
</body>
</html>

这是我从 Rusty Jeans 那里得到帮助的 jQuery。

$('form').submit(function (e) {
e.preventDefault();
$.post('http://links.net/servlet/UserSignUp?
f=755449&postMethod=HTML&m=0&j=MAS2&EMAIL_REQUIRED=T&EMAIL_DATATYPE=email', {
        EMAIL: $('input[name=EMAIL]').val()
    },
    function (data) {
        $( "#dialog" ).dialog( "open" );
    });
});

$( "#dialog" ).dialog({
  autoOpen: false,
  show: "fade",
  hide: "fade",
  open: function(event, ui) {
    var dlg = $(this);
    setTimeout(function(){
    dlg.dialog("close");
    },
    3000); 
  },
  modal: true,
  opacity: 1
});

I've asked this question before and so the other post may be closed. But, I didn't get the full correct answer, something always seem to be missing in the code. I need to submit an email, get a modal box (with a confirm msg), have the modal fade out after 3 seconds, and upon successful submission, another page is loaded.

Basically, the modal box is fading too fast. I want to slow it down. I've been advised to remove the

</form><form> 

tags. Although the modal does slow down when I remove those tags, now I don't get the "welcome" page after submission. The page just seems to post back to itself instead of submitting. I've been trying to work this for five days, I have no idea what I'm doing wrong... I appreciate all answers. Thanks.

Here is my code:

<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js">
</script>
<script src="http://recp.rm04.net//ui/library/formValidate.js" language="javascript">
    </script>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/ui-
  lightness/jquery-ui.css" rel="stylesheet" type="text/css">

<STYLE TYPE="text/css">
     BODY, .BODY, TD
     {  color: ;
        font-size: ;
        font-family: ;
        font-weight: ;
        text-decoration: ;
        font-style: ;
     }
     </STYLE>
</head>
<body vlink="" alink="" link="" bgcolor="">
<!--  demo -->
<div class="demo">
<div id="dialog" title="Basic dialog">
<p>Email submitted successfully.  Thank you for signing up!</p>
</div>
</div>

<!-- End demo -->
<br>
<br>
<table border="0" cellspacing="0" cellpadding="5">
<form name="form" method="post" action="http://links.mkt41.net/servlet/UserSignUp?
f=755449&postMethod=HTML&m=0&j=MAS2">
<tr>
<td valign="top"><span style="color:#CC0000">*</span></td><td valign="top"
align="left">Email:</td>
<td><input type="hidden" name="EMAIL_REQUIRED" value="T"><input type="hidden" 
name="EMAIL_DATATYPE" value="email"><input type="text" name="EMAIL" value="" 
maxlength="4000"></td>
</tr>
</form>
<form>
<tr>
<td align="center" colspan="3">
<div id="opener">
<input type="button" name="submit" value="Submit" onClick="f_validateForm()"></div>
<script src="js/modal_e-confirm.js" language="javascript"></script>
</td>
</tr>
</form>
</table>
<p>
</p>
<script>f_initializeForm();</script>
</body>
</html>

Here is the jQuery that I had help with from Rusty Jeans here at SO.

$('form').submit(function (e) {
e.preventDefault();
$.post('http://links.net/servlet/UserSignUp?
f=755449&postMethod=HTML&m=0&j=MAS2&EMAIL_REQUIRED=T&EMAIL_DATATYPE=email', {
        EMAIL: $('input[name=EMAIL]').val()
    },
    function (data) {
        $( "#dialog" ).dialog( "open" );
    });
});

$( "#dialog" ).dialog({
  autoOpen: false,
  show: "fade",
  hide: "fade",
  open: function(event, ui) {
    var dlg = $(this);
    setTimeout(function(){
    dlg.dialog("close");
    },
    3000); 
  },
  modal: true,
  opacity: 1
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷雾森÷林ヴ 2024-12-09 17:07:37

经过大量调查,我发现 .php 脚本正在加载欢迎页面。我不了解 PHP,但此操作影响了我的模式弹出窗口的行为。一旦删除了欢迎页面功能,该模式就会按预期工作。

After much investigation, I've found that a .php script was loading a welcome page. I don't know PHP, but this action was affecting the behavior of my modal popup. Once that was welcome page functionality was removed, the modal worked as expected.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文