为什么此POST请求返回405

时间:2020-02-05 23:48:49

标签: ajax laravel http post get

我对路线有疑问。我将路线声明为发布,并且表单具有发布方法, 但是当我提交表单时,出现405错误。也是允许的方法GET和HEAD。这是带有方法post的AJAX调用。

var form = $('#typeCreateForm');
                e.preventDefault();
                $.ajaxSetup({headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')}});
                    $.ajax({
                        type: "POST",
                        url: "{{route('admin.type.store')}}",
                        data: form.serialize(),
                        success: function(data){
                            console.log(data);
}
});

这是我的路线

// all routes name are prefixed with admin
Route::post('evenment/type/index/store','TypeController@store')->name('type.store');

0 个答案:

没有答案
相关问题