Support the ongoing development of Laravel.io →
posted 7 years ago
Last updated 2 years ago.
0

I had this same problem when creating a todo feature with ajax and this is what I had to do to get it to work.

I added this to the head

<meta name="csrf-token" content="{{ csrf_token() }}">

I added this to the js file above the ajax request

$.ajaxSetup({
headers: {
    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  }
});
     
Last updated 7 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

finger finger Joined 23 Jan 2017

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.