我正在尝试将 Ajax 与 icontact 一起使用。我的代码使表单提交,但它显示了一条错误消息,尽管表单正常工作并且详细信息已放入列表中。
$('.error').hide();
$('.erroremail').hide();
$('#successcontainer').hide();
function verifyRequired()
{
var eReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; // regex to check valid email
var email = $('input[name="fields_email"]').val();
var name = $('input[name="fields_fname"]').val();
var phone = $('input[name="fields_phone"]').val();
var data = $("#form-popup").serialize()
if (email == "") {
$('input[name="fields_email"]').focus();
$('.error').show();
return false;
} else if (!eReg.test(email)) {
$('input[name="fields_email"]').focus();
$('.erroremail').show();
return false;
}
else if (name == "") {
$('input[name="fields_name"]').focus();
$('.error').show();
return false;
}
else if (phone == "") {
$('input[name="fields_phone"]').focus();
$('.error').show();
return false;
}
else {
$.ajax({
url: "https://app.icontact.com/icp/signup.php",
type: "POST",
data: data,
success: function(){
alert('success')
},
error: function(){
alert('failure')
},
});
return false;
}
}
所以表单提交细节很好,但显示失败消息?
所以我快到了,有人知道为什么吗?
干杯
这里也是表格
<form id="form-popup" method="post" action="" name="icpsignup" accept-charset="UTF-8" onsubmit="return verifyRequired();" >
<input type="hidden" name="redirect" value="http://www.icontact.com/www/signup/thanks.html">
<input type="hidden" name="errorredirect" value="http://www.icontact.com/www/signup/error.html">
<input type="text" name="fields_fname" class="input" id="name" placeholder="Full Name" />
<input type="text" name="fields_email" class="input" id="email" placeholder="Email Address" />
<input type="text" name="fields_phone" class="input" id="phone" placeholder="Telephone" />
<input type="submit" id="submit" />
<input type="hidden" name="listid" value="xxxxxxx">
<input type="hidden" name="specialid:xxxxx" value="xxxx">
<input type="hidden" name="clientid" value="xxxxxx">
<input type="hidden" name="formid" value="xxxx">
<input type="hidden" name="reallistid" value="1">
<input type="hidden" name="doubleopt" value="0">
</form>