【问题标题】:issue with text area nic editor data not update?文本区域网卡编辑器数据未更新的问题?
【发布时间】:2020-11-29 02:16:15
【问题描述】:

我遇到了一些问题,其中一个是为什么我收到 419 状态错误,然后我该如何发送到控制器多个数据?

$(document).on( "click", '.submit',function(event) {
event.preventDefault();               
    var nicE = new nicEditors.findEditor('notes');
    var question = nicE.getContent();        
    var editid = $(this).attr('id');

      
    $('.test'+editid).hide();
    $('#test1'+editid).show();
    var formdata= new FormData($('#'+editid)[0]);
    var fileSelect = $("csvdocument").val();
    
    
     $.ajax({
           
           url:"updatenotes",
           type:"POST",
           data: {'formdata':formdata,'question':question, '_token': "$('input[name=_token]').val()"},
           enctype: 'multipart/form-data',
           contentType: false,
           cache: false,
           processData: false
           }).success(function(response)
           {

            alert('response');
            //location.reload();
            
          });

【问题讨论】:

    标签: jquery ajax laravel-5


    【解决方案1】:

    419 Status Code 表示您没有通过任何 CSRF 令牌。基本上,Laravel 使用 resources 目录中的 bootstrap.js 文件配置 ajax default csrf 标头,因此请检查它是否未被注释/删除。它应该是这样的:

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

    其次,检查刀片模板 head 部分中的 元标记,它应该包含类似这样的内容。

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

    之后,从您的请求正文中删除 _token 输入,您的问题应该得到解决。

    【讨论】:

      猜你喜欢
      • 2012-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-25
      • 2018-10-31
      • 1970-01-01
      • 2021-12-22
      相关资源
      最近更新 更多