Last active
June 14, 2018 01:00
-
-
Save joeswann/c900df009c6dd4dce3b4 to your computer and use it in GitHub Desktop.
[campaignmonitor.js] Campaign monitor ajax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form class="form-newsletter" action="http://xxxx.createsend.com/t/d/s/xxxx/" method="post" > | |
<h3>Newsletter</h3> | |
<div class="success"> | |
Thankyou for signing up! | |
</div> | |
<div class="error"> | |
Please check your email address is correct. | |
</div> | |
<input name="cm-xxxx-xxxx" type="email" placeholder="Email Address" required /> | |
<button type="submit" value="Sign Up" name="submit">Sign Up</button> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Handler for Campaignmonitor form | |
handlerNewsletterSubmit: function() { | |
var $form = $('footer .newsletter form'); | |
var $success = $form.find('.success'); | |
var $error = $form.find('.error'); | |
$form.submit(function(e) { | |
e.preventDefault(); | |
$error.hide(); | |
$.getJSON(this.action + "?callback=?", | |
$(this).serialize(), | |
function(data) { | |
if (data.Status === 400) { | |
$error.text(data.Message).show(); | |
} else { // 200 | |
$form.find('input').val(''); | |
$success.show(); | |
js.utilRemoveLightbox(); | |
} | |
} | |
); // end getJson | |
}); // end submit | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment