Support the ongoing development of Laravel.io →
Security Requests Session
Last updated 2 years ago.
0
$(function () {
            $.ajaxSetup({
                    headers: {
                            'X-XSRF-TOKEN': $('meta[name="_token"]').attr('content')
                    }
            });
    });

Add this to your $.ajax which you should use instead of $.post.

0

scosec said:

$(function () {
           $.ajaxSetup({
                   headers: {
                           'X-XSRF-TOKEN': $('meta[name="_token"]').attr('content')
                   }
           });
   });

Add this to your $.ajax which you should use instead of $.post.

I actually tried using this example code before and I get the same result. I still get the same error when I comment out everything except 'Illuminate\Cookie\Middleware\EncryptCookies' in app.php's $app->middleware() method

0

What i need to do is only including this on my data of ajax

$.ajax({
  data: {_token:'{{ csrf_token() }}'}
})

no need extra koding, and it works ! LoL

0

Sign in to participate in this thread!

Eventy

Your banner here too?

donth77 donth77 Joined 15 Dec 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.