Created
April 3, 2015 22:47
-
-
Save soumyabrataghosh/e6d3ca73b178226b2bc2 to your computer and use it in GitHub Desktop.
FormKeep + AJAX Submission + Success Message + URL Location + WordPress
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 method="POST" class="ajax"> | |
<input type="text" name ="URL Location" id="urlLoc" style="display:none"> | |
<input type="text" name="name" placeholder="Your Name" required> | |
<input type="email" name="email" placeholder="Your Email" required> | |
<input type="submit" value="Submit"> | |
<div class="alert-success"></div> | |
</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
var elem = document.getElementById("urlLoc"); | |
elem.value = window.location.href; | |
var form = jQuery("form.ajax"); | |
form.submit(function(e) { | |
e.preventDefault(); | |
var formkeepID = "00000000000"; //Insert FormKeep form ID | |
var successMsg = "Thank you! We'll get back to you shortly."; | |
jQuery.ajax({ | |
type: 'POST', | |
url: 'https://formkeep.com/f/' + formkeepID, | |
data: jQuery(this).serialize(), | |
success: function() { | |
form.find("input, button, textarea").prop('disabled', true).css({"opacity": 0.5}); | |
form.find(".alert-success").text(successMsg).fadeIn(500); | |
}, | |
error: function() { | |
alert('Error!'); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment