Last active
July 13, 2016 07:47
-
-
Save rob1121/5ec280681fe83df83082577d74d4a26f to your computer and use it in GitHub Desktop.
HTTP POST laravel ajax request
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
{{-- place at your header meta tag --}} | |
<meta id="_token" value="{{ csrf_token() }}"> |
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
//Jquery syntax for laravel x-csrf authentication | |
$.ajaxSetup({ | |
headers: { | |
'X-CSRF-TOKEN': $('#_token').attr('value') | |
} | |
}); |
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
//vue js syntax for laravel x-csrf authentication | |
Vue.http.headers.common['X-CSRF-TOKEN'] = document.querySelector('#_token').getAttribute('value'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment