Skip to content

Instantly share code, notes, and snippets.

@niksudan
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niksudan/f7d29b51e2ecc8c4ab4f to your computer and use it in GitHub Desktop.
Save niksudan/f7d29b51e2ecc8c4ab4f to your computer and use it in GitHub Desktop.
Ajax form submission [jQuery]
/**
* jQuery Ajax Form Submission
*/
jQuery( document ).ready(function( $ ) {
$( document ).on( 'click', 'input[type="submit"]', function() {
var form = $( this ).closet( 'form' );
$.post( form.attr( 'action' ), form.serialize(), function( data ) {
// Success
} ).error( function() {
// Error
} );
} );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment