Quantumass soufiane Quantumass soufiane - 4 months ago 66
Ajax Question

MethodNotAllowedHttpException - CSRF -laravel 5.2

I'm using ajax to post a request then it refresh a part of the site with jquery function "load" and it's working good but when I try to redo this post it says MethodNotAllowedHttpException I think the problem in laravel csrf protection because after I refresh the whole page it works fine
my problem is how can I save the csrf token even if I refresh a part of site ?
** thanks in advance ** (ᵔᴥᵔ)

Answer

It is usually recommended to pass the csrf token to the web-page in meta tags (which are inside <head></head> tags)

 <meta name="_token" content="{{  csrf_token() }}" />