Skip to content

Instantly share code, notes, and snippets.

@mikemartin
Last active March 28, 2017 21:05
Show Gist options
  • Save mikemartin/180c0c7dbd00dd1f58a173cbab70dd38 to your computer and use it in GitHub Desktop.
Save mikemartin/180c0c7dbd00dd1f58a173cbab70dd38 to your computer and use it in GitHub Desktop.
submit statamic form with ajax
$(function() {
$.ajaxSetup({
headers: { 'X-CSRF-TOKEN': $('input[name="_token"]').val() }
});
var form = $('.contact-form');
form.submit(function(e) {
e.preventDefault();
$.ajax({url: form.attr('action')})
.done(function() {
console.log('yay')
})
.fail(function() {
console.log('boo')
});
return false;
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment