Last active
August 29, 2015 14:05
-
-
Save singpolyma/a4e69e0314487370885c to your computer and use it in GitHub Desktop.
Submit any form with AJAX and 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
$('#thing form').submit(function(e) { | |
var $this = $(this); | |
e.preventDefault(); | |
$.ajax({ | |
type: this.method, | |
dataType: "JSON", | |
url: this.action, | |
data: $this.serialize(), | |
success: function() { | |
// Display success message or something | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment