Skip to content

Instantly share code, notes, and snippets.

@anton21m
Forked from mdsalim/mailchimp ajax activation
Created June 22, 2020 12:22
Show Gist options
  • Save anton21m/14802fef7e68c5c18889c2ddb4a9ad6a to your computer and use it in GitHub Desktop.
Save anton21m/14802fef7e68c5c18889c2ddb4a9ad6a to your computer and use it in GitHub Desktop.
Markup
-----------
<div class="subscribe-widget clearfix">
<h4>Subscribe to Our Newsletter</h4>
<!-- ===== MAILCHIMP FORM STARTS ===== -->
<form class="mailchimp inputSubscribeDiv">
<!-- SUBSCRIPTION SUCCESSFUL OR ERROR MESSAGES -->
<input type="email" name="subscribe" id="subscriber-email" placeholder="Enter your Email" class="form-control">
<button type="submit" id="subscribe-button" class="btn btn-blue ">Subscribe</button>
<h5 class="subscription-success"> </h5>
<h5 class="subscription-error"> </h5>
<label class="subscription-label" for="subscriber-email"></label>
</form>
<!-- /END MAILCHIMP FORM STARTS -->
</div>
jQuery activation
-----------------------
(function ($) {
"use strict";
// mailchimp start
if ($('.mailchimp').length > 0) {
/* MAILCHIMP */
$('.mailchimp').ajaxChimp({
language: 'es',
callback: mailchimpCallback,
url: "https://themepure.us14.list-manage.com/subscribe/post?u=5b0af3eccc324cd420b6ae5e5&amp;id=2416850e34" //Replace this with your own mailchimp post URL. Don't remove the "". Just paste the url inside "".
});
}
function mailchimpCallback(resp) {
if (resp.result === 'success') {
$('.subscription-success').html('<i class="fa fa-check"></i><br/>' + resp.msg).fadeIn(1000);
$('.subscription-error').fadeOut(500);
} else if (resp.result === 'error') {
$('.subscription-error').html('<i class="fa fa-times"></i><br/>' + resp.msg).fadeIn(1000);
}
}
$.ajaxChimp.translations.es = {
'submit': 'Submitting...',
0: 'We have sent you a confirmation email',
1: 'Please enter a value',
2: 'An email address must contain a single @',
3: 'The domain portion of the email address is invalid (the portion after the @: )',
4: 'The username portion of the email address is invalid (the portion before the @: )',
5: 'This email address looks fake or invalid. Please enter a real email address'
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment