Last active
April 2, 2017 14:10
-
-
Save imvarunkmr/3dac524c43943e03939651fbb83ccee4 to your computer and use it in GitHub Desktop.
Processing an ajax form using jQuery
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').submit(function(e) { | |
// get the form data | |
formData = $(this).serialize(); | |
formData += '&action=submit_contact_form'; | |
// process the form | |
$.ajax({ | |
type : 'post', | |
url : localData.ajax_url, | |
data : formData, | |
dataType : 'json' | |
}).done(function(data) { | |
// use the data | |
console.log(data); | |
}); | |
// Prevent the default click action | |
e.preventDefault(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment