Last active
March 28, 2017 21:05
-
-
Save mikemartin/180c0c7dbd00dd1f58a173cbab70dd38 to your computer and use it in GitHub Desktop.
submit statamic form with ajax
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
$(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