Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

aulapantheon's avatar

CSRF Token Not Found even if it's in meta tag and ajaxSetup

I want to ask a help. Why does console tell me "CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token" even if I have and $.ajaxSetup and Inspector shows the meta CSRF? With this problem, I can't do AJAX. Please help me

0 likes
7 replies
rin4ik's avatar

do you have this tag in your head section of blade template? if not include it

<meta name="csrf-token" content="{{ csrf_token() }}">
aulapantheon's avatar

@rin4ik : I've overwritten it so many times but it's still not working... it's really strange

rin4ik's avatar

@mending3 php artisan config:clear and composer dump-autoload hard refresh the browser with ctrl+f5 and try again

tahmasebi's avatar

I had this problem, finally, I found I was written something wrong in my view that causes the page HTML code totally print in an incorrect way. (@include out of @section)

check your page source to see your HTML code is correct.

1 like
cmandujano's avatar

Hello, all. I have the same problem but though I've checked the structure of the blade view (the only one that has given me this problem in over 90 blade files that my project has so far) and I find nothing wrong with it. I'm not using any include sentences and I have the meta tag mentioned before. I even tried rin4ik's suggestion to clear cache and composer dump-autoload the project but the ugly message is still there. I have absolutely no idea why this could be happening. Anybody has another suggestion? =/

mstrauss's avatar

Can you show the AJAX request and possibly the view as well? (And if the CSRF token is not in the view, then please show the include file that has it).

siangboon's avatar

the browser won't lie, it's better to double check the page source of the rendered html to find out the csrf_token input and check whether is it included in your ajax submission properly.

Please or to participate in this conversation.