Created
March 9, 2015 09:39
-
-
Save TimGeyssens/8038825ba8642730f4ee to your computer and use it in GitHub Desktop.
Forms ajax submit
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
$('input[type=submit]').not('.cancel').click(function (evt) { | |
evt.preventDefault(); | |
var self = $(this); | |
var frm = self.closest('form'); | |
frm.validate(); | |
if (frm.valid()) { | |
$.ajax({ | |
cache: false, | |
async: true, | |
type: "POST", | |
url: frm .attr('action'), | |
data: frm.serialize(), | |
success: function (data) { | |
alert(data); | |
//show success message | |
} | |
}); | |
self.attr('disabled', 'disabled'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment