Created
May 13, 2016 23:26
-
-
Save nflint/e4a706085ba8777fd5dcb96ce9805bdd to your computer and use it in GitHub Desktop.
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
// Uses this script: https://limonte.github.io/sweetalert2/ | |
var footernewsletterSubscriberFormDetail = new VarienForm("footer-newsletter-validate-detail"), | |
val_form = new VarienForm("footer-newsletter-validate-detail"); | |
jQuery("#footer-newsletter-validate-detail").submit(function(e) { | |
if (val_form.validator && val_form.validator.validate()) { | |
var t = jQuery(this).serializeArray(), | |
o = jQuery(this).attr("action"), | |
r = swal({ | |
title: "One moment please...", | |
showCancelButton: !0, | |
confirmButtonText: "Submit" | |
}); | |
swal.enableLoading(); | |
jQuery.ajax({ | |
url: o, | |
type: "POST", | |
data: t, | |
onLoading: r, | |
success: function(e, t, o) { | |
swal.close(), swal({ | |
title: "Cool it worked.", | |
text: t, | |
type: "success", | |
confirmButtonColor: "#DD6B55", | |
confirmButtonText: "Close", | |
closeOnConfirm: !1 | |
}) | |
}, | |
error: function(e, t, o) { | |
swal({ | |
title: "Uh oh. ", | |
text: "It looks like there was a problem with your submission. Please try again later", | |
type: "error", | |
confirmButtonColor: "#DD6B55", | |
confirmButtonText: "Close", | |
closeOnConfirm: !1 | |
}) | |
} | |
}), this.reset(), e.preventDefault() | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note to self:
this is the original script
<script type="text/javascript"> //<![CDATA[ var footernewsletterSubscriberFormDetail = new VarienForm('footer-newsletter-validate-detail'); var val_form = new VarienForm('footer-newsletter-validate-detail'); jQuery("#footer-newsletter-validate-detail").submit(function(e) { if (val_form.validator && val_form.validator.validate()) { var postData = jQuery(this).serializeArray(); var formURL = jQuery(this).attr("action"); jQuery.ajax( { url : formURL, type: "POST", data : postData, success:function(data, textStatus, jqXHR) { alert('success'); }, error: function(jqXHR, textStatus, errorThrown) { alert('Failure'); } }); this.reset(); //form field reset e.preventDefault(); //STOP default action e.unbind(); //unbind. to stop multiple form submit. } }); //]]> </script>