Last active
August 29, 2015 14:11
-
-
Save niksudan/f7d29b51e2ecc8c4ab4f to your computer and use it in GitHub Desktop.
Ajax form submission [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
/** | |
* 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