【发布时间】:2014-09-18 20:17:39
【问题描述】:
提交时一个简单的弹出 HTML 表单需要执行两个操作。 1.将客户信息发送到现有数据库 2. 将客户重定向到感谢页面。
在另一个 Stackoverflow 成员的帮助下,能够处理此代码。但是,代码不起作用。我觉得我对代码做了一些非常错误的事情,很抱歉无法弄清楚。请帮忙!
目前,表单正在发送到数据库,但重定向到现有的邮件列表注册页面,如果我将操作更改为感谢页面,那么表单将发送到感谢页面,但不会提交到数据库。
我更喜欢使用Jquery,我对PHP不太熟悉,如果有人可以指导我,我也可以实现PHP。即使在电子邮件地址输入中没有输入任何内容,表单也会被重定向。有没有办法告诉客户输入有效的电子邮件地址,然后将他带到Thankyou 页面?谢谢
数据库地址:“http://www.mywebsite.com/MailingList_subscribe.asp” 感谢页面地址:“https://www.mywebsite.com/Articles.asp?ID=252”
HTML 标题
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js">
$(document).ready(function(){
$('#formId').submit(function(){
$.ajax({
type: "POST",
url: "http://www.mywebsite.com/MailingList_subscribe.asp",
context: document.body
}).success(function() {
location.href = "https://www.mywebsite.com/Articles.asp?ID=252";
});
});
)};
</script>
HTML 正文:
<form name="MailingList" id="formId" method="post" action="http://www.mywebsite.com/MailingList_subscribe.asp">
<input type="text" name="emailaddress" placeholder="Email Address" maxlength="100" size="28"> <br>
<input type="submit" name="Submit" value="Submit" width="260px">
</form>
CSS:
input[type=text] {
padding:1px; border:1px solid #c6c7cc;
box-shadow: inset 0 1px 1px
-webkit-border-radius: 13px;
width: 98%;
font-size:14px;
font-family: Lucida Grande;
font-weight: regular;
margin-left: 2px;
margin-top:10px;
}
input[type=submit] {
background: #9B1C1F;
width: 100%;
font-family: Lucida Grande;
color: #ffffff;
font-weight: bold;
font-size:18px;
text-align:left;
margin-top:10px;
padding:5px 15px;
margin-left:0px;
border:0 none;
cursor:pointer;
display: inline-block;
}
【问题讨论】:
-
使用 jquery 验证插件来验证电子邮件。
-
我建议您将
location.href = "https://www.mywebsite.com/Articles.asp?ID=252";添加到http://www.mywebsite.com/MailingList_subscribe.asp上的“数据库”脚本中 -
.success()回调已弃用,取而代之的是.done()。有关更多详细信息,请参阅链接部分中的yellow box...
标签: javascript php jquery html css