laravel TokenMismatchException in ajax request

后端 未结 5 852
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-29 09:25

i\'m using resource group and use this filter to resolve TokenMismatchException problem:

Route::filter(\'csrf\', function($route, $request) {
           


        
5条回答
  •  我在风中等你
    2020-11-29 09:57

    You have to insert a hidden input with the _token and later get that value as you do to get the other form fields in your ajax post.

    
    

    An another method,

    On your view you can set an object with the _token

    
    

    and later on your ajax call you can get the _token from the object like this:

    var token = _globalObj._token;
    

    and include it on your ajax post.

提交回复
热议问题