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="h开发者_C百科ttp://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
});
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.
精彩评论