Skip to content

Instantly share code, notes, and snippets.

@glennr
Last active June 20, 2016 00:46
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 glennr/e371cc614a91c5cc0de1970d01a0d581 to your computer and use it in GitHub Desktop.
Save glennr/e371cc614a91c5cc0de1970d01a0d581 to your computer and use it in GitHub Desktop.
$(document).ready(function() {
$('#contact').submit(function(e) {
var form = $(this);
var endpoint = form.prop('action');
var data = form.serialize();
var submitButton = $('button', form);
e.preventDefault();
$.ajax({
type: 'POST',
url: endpoint,
headers: {
Accept : "application/json; charset=utf-8",
},
data: data,
beforeSend: function() {
submitButton.prop('disabled', 'disabled');
}
})
.done(function(data) {
submitButton.prop('disabled', false);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment