Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel csrf ajax

<!-- Add this to header -->
<meta name="csrf-token" content="{{ csrf_token() }}">

<!-- Add this to script -->
<script>
$.ajaxSetup({
    headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    }
});
</script>
 
PREVIOUS NEXT
Tagged: #laravel #csrf #ajax
ADD COMMENT
Topic
Name
6+4 =