Created
September 30, 2017 20:52
-
-
Save solancer/4832b34730faf72fe44b91a16c1349cb to your computer and use it in GitHub Desktop.
Generic contact form AJAX function
This file contains hidden or 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
| $(document).ready(function() { | |
| $("#contactForm").submit(function(e) { | |
| e.preventDefault(); | |
| var o = $(this).serializeArray(), | |
| t = $(this).attr("action"), | |
| i = $("#contactFormResponse"), | |
| n = $("#cfsubmit"); | |
| n.text(); | |
| return n.text("Sending..."), $.ajax({ | |
| url: t, | |
| type: "POST", | |
| data: o, | |
| success: function(e) { | |
| i.html(e), n.fadeOut(1e3), $("#contactForm").each(function() { | |
| this.reset().fadeOut(1e3) | |
| }) | |
| }, | |
| error: function(e) { | |
| alert("Error occurd! Please try again") | |
| } | |
| }), !1 | |
| }) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment