How to Turn Your MailChimp Subscribe to AJAX (jQuery)
- Published 30th Nov 2016
Last edited 30th Nov 2016
I’ll say it again. I love jQuery. There will never be a replacement.
Below is a cool little snippet I made to transform your MailChimp sign up form to an AJAX enabled one. One of the advantages being – you’re able to set your own redirect or set of actions afterwards. Also, no nasty popups:
var url = jQuery(this).prop('action'); // the script where you handle the form input.
data: jQuery("#mc-embedded-subscribe-form").serialize(), // serializes the form's elements.
if(data.result == 'success') window.location.href = 'https://example.franciskim.co/thank-you.html';
e.preventDefault(); // avoid to execute the actual submit of the form.
Obviously, change the thank-you.html page to your liking but that should in theory work itself out.
Have fun! Peace!