我正在开发一个MailChimp订阅表单,需要将表单$ _POST数据发送到MailChimp,但实际上并没有加载成功页面。即我希望它在提交时加载自定义JS。这就是我到目前为止所拥有的。显然preventDefault
打破了提交。非常感谢任何想法:
<!-- Begin MailChimp Signup Form -->
<link href="http://cdn-images.mailchimp.com/embedcode/slim-081711.css" rel="stylesheet" type="text/css">
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<style type="text/css">
#mc_embed_signup{background:#fff; clear:left; font:14px Helvetica,Arial,sans-serif; }
</style>
<form action="http://yourmove.us5.list-manage.com/subscribe/?u=00000444444333331&id=aaa111444iiii" method="POST" id='mc_embed_form'>
<div id="mc_embed_signup">
<h3>Subscribe to <em>Our Newsletter/em> for your free download:</h3>
<input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="email address" required>
<div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button" novalidate></div>
</div>
</form>
<script type="text/javascript">
$(document).ready(function(){
$("#mc_embed_form").submit(function (){
event.preventDefault();
showConfirmation();
});
});
function showConfirmation() {
alert("successful");
}
</script>
答案 0 :(得分:0)
您缺少函数中的参数,请尝试以下参数:
$(document).ready(function(){
$("#mc_embed_form").submit(function (event){
event.preventDefault();
showConfirmation();
});
});