TokenMismatchException in VerifyCsrfToken.php line 53 in Laravel 5.1

前端 未结 13 1183
独厮守ぢ
独厮守ぢ 2020-12-11 16:47

When I try to login show me token error. I have checked token in view form it\'s right and when comment \\App\\Http\\Middleware\\VerifyCsrfToken::class, in the

相关标签:
13条回答
  • 2020-12-11 17:26

    It works for me.

    <meta name="csrf-token" content="{{ csrf_token() }}" />
    
    <script>
    function getMessage(){ 
    $.ajax({
       headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
       type:'POST',
       url:'/getmsg',
       // data:'_token = <?php echo csrf_token() ?>',
       success:function(data){
          $("#msg").html(data.msg);
       }
     });
    }
    </script>
    
    {{ Form::button('Replace Message',['onClick'=>'getMessage()']) }}
    
    0 讨论(0)
提交回复
热议问题