Skip to content

Instantly share code, notes, and snippets.

@charrondev
Created March 21, 2016 02:30
Show Gist options
  • Save charrondev/2e0352aa88a1590b11ac to your computer and use it in GitHub Desktop.
Save charrondev/2e0352aa88a1590b11ac to your computer and use it in GitHub Desktop.
// hijack the form submit to add a callback.
$('#appointment-form').submit((event) => {
$.ajax({
url: $('#appointment-form').attr('action'),
type: 'post',
data: $('#appointment-form').serialize(),
success: () => {
$(document.body).toggleClass('appointments-open');
},
error: () => {
$('.appointment__error').toggleClass('appointment__error-visible');
}
});
event.preventDefault();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment