【问题标题】:Invalid Request - Laravel with Ajax无效请求 - 带有 Ajax 的 Laravel
【发布时间】:2021-05-28 14:19:54
【问题描述】:

我正在使用 Laravel,当我尝试通过 Ajax 使用申请时,我在 VS Code 中的终端显示此消息(不在控制台中显示任何消息):

[Fri May 28 11:03:41 2021] 127.0.0.1:57828 Invalid request (Foi for�ado o cancelamento de uma conex�o existente pelo host remoto.)

我有一个这样的 Ajax 代码:

$.ajax({
        type: "POST",
        url: "/comercial/relacoes/clientes/entrega-assinatura",
        data: {
            '_token': "{{ csrf_token() }}",
            'id_contato': "{{ $contato_id }}",
            'assinatura_gerente': $('#ass-gerente').attr('src'),
            'assinatura_cliente': $('#ass-cliente').attr('src'),
            'observacao': $('#observacoes').val(),
            'user_update': $('#input-hidden').val(),
        },
        success: function (response) {
            if(response.errors)
            {
                swal('Oops!', display_errors(response.errors), 'error');
                btn_enable(btn, btn_text);
            }
            else {
                swal_redirect('Ok!', response, 'success');
                console.log(response);
                btn_enable(btn, btn_text);
                window.open('/comercial/relacoes/clientes/ae2112f247772ea3e98aef75770435e6', '_self');
            }
        },
        error: function(response) {
            console.log(response);
            btn_enable(btn, btn_text);
        }
    });

路线:

Route::post('/relacoes/clientes/entrega-assinatura', 'Modules\Comercial\ComercialReqController@entrega_assinatura');

但有一个不确定的点:有时会显示此错误,但并非总是如此......但仅在这条路线上。

【问题讨论】:

  • 我不会葡萄牙语,但"brindes-cliente" 不是'/relacoes/clientes/entrega-assinatura'
  • 设置 dataType: json 并检查它是否有效
  • 抱歉,我编辑了问题。 Ajax 是不正确的,但现在是正确的
  • @AliQorbani 不起作用

标签: php ajax laravel


【解决方案1】:

你应该替换 网址:“/relacoes/clientes/entrega-assinatura” 和 网址:“/comercial/relacoes/clientes/entrega-assinatura”

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-09-28
    • 2021-11-18
    • 2018-02-17
    • 2018-03-15
    • 1970-01-01
    • 2019-06-21
    • 1970-01-01
    • 2022-09-27
    相关资源
    最近更新 更多