0

I am working on a MailChimp subscription form that will need to send the form $_POST data to MailChimp, but not actually load the success page. I.e. I want it to load custom JS on submission. This is what I have so far. Obviously the preventDefault is breaking the submission. Any thoughts are greatly appreciated:

 <!-- 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>
Jamie H.
  • 315
  • 1
  • 2
  • 10

1 Answers1

0

You are missing a parameter in your function, try this one:

$(document).ready(function(){
    $("#mc_embed_form").submit(function (event){
            event.preventDefault();
            showConfirmation();
    });
}); 
Zvonko Biskup
  • 393
  • 2
  • 9
  • First, thanks for the tip. However, this seems to still just run the JS, but not actually submit the form to MailChimp. – Jamie H. Sep 10 '12 at 18:08
  • You have to submit it with AJAX or something. You can see one solution here: http://stackoverflow.com/questions/8425701/ajax-mailchimp-signup-form-integration – Zvonko Biskup Sep 11 '12 at 13:09