此表单适用于 Chrome、FF、Safari。POST
通过作品,我的意思是当我点击提交按钮时,我可以看到请求被发送出去。
但是,在 IE 中作为 IE9 的开发人员工具中,我看不到任何POST
请求。任何想法为什么?
这是一个临时站点的链接以帮助调试: http: //polar-ravine-7414.herokuapp.com/
重现错误的步骤:
- 加载页面
- 忽略弹窗
- 点击提交按钮
POST
我在 Chrome 开发工具和 FF Firebug 中看到了一个请求,但在 IE 开发者工具中没有
更新
根据 Eliran 的建议,我已经更新了选择器。但是,我仍然看不到在 IE 开发者工具网络栏中发出的 POST 请求。
更新2
我可能应该补充一点,该页面托管在与发布表单的服务器不同的服务器上。现在这可能是由于浏览器阻止了跨浏览器请求吗?
HTML
<form name="newsletter-subscription-en" id="form" action="https://abc.com/e/f2" method="post">
<input type="hidden" name="elqFormName" value="newsletter-subscription-en">
<input type="hidden" name="elqSiteID" value="1795">
<input type="hidden" id="firstNameField" name="C_FirstName" value="">
<input type="hidden" id="lastNameField" name="C_LastName" value="">
<div id="step1" class="block">
<div id="circle_1" class="circle">
<div id="bullet_1" class="left white is-bold s24"><span class="bullet">1.</span></div>
</div>
<div id="bullet_spacer_1" class="left"> </div>
<div class="content">
<p class="white is-regular s18">This is the email you will be subscribing with, if you'd like to change it, please enter here now.</p>
<label id="label_email" class="white is-bold s22" for="emailField">YOUR EMAIL: </label>
<input id="emailField" value="" name="C_EmailAddress" type="text">
</div>
</div>
<div class="clearfix"></div>
<div id="step2" class="block">
<div id="circle_2" class="circle">
<div id="bullet_2" class="left white is-bold s24"><span class="bullet">2.</span></div>
</div>
<div id="bullet_spacer_2" class="left"> </div>
<div class="content">
<p class="white is-regular s18">Choose your newsletter:</p>
<div id="checkbox_customer" class="left">
<div class="box">
<input id="elqInput31" type="checkbox" name="elqInput31" checked="checked">
<label class="white is-bold s20" for="elqInput31">CUSTOMER</label>
</div>
<div class="arrow-up"></div>
<div class="nip_box">
<span class="is-bold s12">Customer Newsletter</span>
<p class="is-light s115">
Monthly collective on latest industry news, technology pieces from experts, product resources, success examples and exclusive customer promotions.
</p>
</div>
</div>
<div id="spacer" class="left"> </div>
<div id="checkbox_training" class="left">
<div class="box">
<input id="elqInput32" type="checkbox" name="elqInput32" checked="checked">
<label class="white is-bold s20" for="elqInput32">TRAINING</label>
</div>
<div class="arrow-up"></div>
<div class="nip_box">
<span class="is-bold s12">Training Newsletter</span>
<p class="is-light s115">
Exclusive newsletter for current and aspiring IT professionals. Updated with training tips and tricks, industry news, free online training resources and latest information on available certification and training.
</p>
</div>
</div>
</div>
</div>
<div class="clearfix"></div>
<div id="step3" class="block">
<div id="circle_3" class="circle">
<div id="bullet_3" class="left white is-bold s24"><span class="bullet">3.</span></div>
</div>
<div id="bullet_spacer_3" class="left"> </div>
<div class="content">
<div id="submit" class="box right">
<span class="right white is-bold s24">SIGN-UP</span>
</div>
</div>
</div>
<div class="clearfix"></div>
</form>
JavaScript
根据 Eliran 的回答更新
$(document).ready(function() {
$('#submit').click(function () {
//Get the data from all the fields
var email = $('input[name=C_EmailAddress]');
var trainingNewsletter = $('input[name=elqInput31]');
var customerNewsletter = $('input[name=elqInput32]');
var regExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
var validationPass = true;
var form = $('#redhat_form');
if (validationPass === true) {
$.post(form.attr('action'), form.serialize(), function(data) {});
$('#alert').removeClass('hide');
$('#alert').removeClass('alert-success');
$('#alert').removeClass('alert-error');
$('#alert_text').remove();
$('#alert').addClass('alert-success');
$('#alert').append('<p id="alert_text" class="is-regular s16">Thank you for subscribing.</p>');
$('#emailField').val("");
//window.location='http://afternoon-leaf-7565.herokuapp.com/thankyou/';
return false;
}
});
});