Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * MailChimp working newsletter
- * read more http://stackoverflow.com/a/15120409/477958
- */
- $.each($('form.mc-embedded-subscribe-form'), function(index, el) {
- var newsletterForm = $(el);
- newsletterForm.h5Validate();
- newsletterForm.submit(function(e) {
- e.preventDefault();
- // If data-nldemo="0" attribute don't do nothing, just throw an alert.
- if(newsletterForm.attr('data-nldemo') && cform.attr('data-nldemo') == "0") {
- $.magnificPopup.open({
- items: {
- src: '<div class="white-popup">Newsletter form disabled on demo!</div>',
- type: 'inline'
- },
- closeBtnInside: true
- });
- return;
- }
- if(newsletterForm.h5Validate('allValid')) {
- var notifContainer = newsletterForm.next('.notification_container');
- $.ajax({
- type : newsletterForm.attr('method'),
- url : newsletterForm.attr('action'),
- data : newsletterForm.serialize(),
- cache : false,
- dataType : 'json',
- contentType : "application/json; charset=utf-8",
- error : function(err) {
- notifContainer.html('<div class="alert alert-warning">Could not connect to server. Please try again later.</div>');
- },
- success : function(data) {
- if (data.result != "success") {
- var message = data.msg.substring(4);
- notifContainer.html('<div class="alert alert-warning">'+message+'</div>');
- } else {
- var message = data.msg;
- notifContainer.html('<div class="alert alert-success">'+message+'</div>');
- }
- }
- });
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement