Skip to content

Instantly share code, notes, and snippets.

@rob1121
Last active July 13, 2016 07:47
Show Gist options
  • Save rob1121/5ec280681fe83df83082577d74d4a26f to your computer and use it in GitHub Desktop.
Save rob1121/5ec280681fe83df83082577d74d4a26f to your computer and use it in GitHub Desktop.
HTTP POST laravel ajax request
{{-- place at your header meta tag --}}
<meta id="_token" value="{{ csrf_token() }}">
//Jquery syntax for laravel x-csrf authentication
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('#_token').attr('value')
}
});
//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