Skip to content

Instantly share code, notes, and snippets.

@garyc40
Created October 3, 2012 15:35
Show Gist options
  • Save garyc40/3827617 to your computer and use it in GitHub Desktop.
Save garyc40/3827617 to your computer and use it in GitHub Desktop.
WordPress AJAX form submission
jQuery('#myForm1').ajaxForm({
data: {
// additional data to be included along with the form fields
},
dataType: 'json',
beforeSubmit: function(formData, jqForm, options) {
// optionally process data before submitting the form via AJAX
},
success : function(responseText, statusText, xhr, $form) {
// code that's executed when the request is processed successfully
}
});
<script src="https://gist.github.com/3827608.js"> </script>
@aghub
Copy link

aghub commented May 4, 2013

the link you sent (https://gist.github.com/3827608.js) is empty.
for anyone needs to enqueue the build in jquery-form of Wordpress, can use this code:

add_action( 'wp_enqueue_scripts', 'inputtitle_submit_scripts' );
function inputtitle_submit_scripts() {
wp_enqueue_script('jquery-form'); // it will load /wp-includes/js/jquery/jquery.form.js
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment