Skip to content

Instantly share code, notes, and snippets.

@TimGeyssens
Created March 9, 2015 09:39
Show Gist options
  • Save TimGeyssens/8038825ba8642730f4ee to your computer and use it in GitHub Desktop.
Save TimGeyssens/8038825ba8642730f4ee to your computer and use it in GitHub Desktop.
Forms ajax submit
$('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