0

我正在处理一个 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>
4

1 回答 1

0

您的函数中缺少一个参数,试试这个:

$(document).ready(function(){
    $("#mc_embed_form").submit(function (event){
            event.preventDefault();
            showConfirmation();
    });
}); 
于 2012-09-10T18:04:47.137 回答