Laravel错误405(不允许使用方法)Ajax发布 [英] Laravel error 405(Method Not Allowed) Ajax Posting

查看:185
本文介绍了Laravel错误405(不允许使用方法)Ajax发布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我想使用ajax将数据发送到我的控制器.

Hello i wnat to send my data with ajax to my controller.

我的代码

AJAX

  $.ajax( {
    type:'POST',
    header:{
      'X-CSRF-TOKEN':$('meta[name="csrf-token"]').attr('content')
    },
    url:"{{route('race.post')}}",
    data:{
      _token: "{{ csrf_token() }}",
      dataType: 'json', 
      contentType:'application/json', 
    }


})
.done(function() {
    alert('success');
})
.fail(function() {
    alert("error");
});

CONTROLLER

 public function Points(Request $request){
    $test = $request->input('data');
    return "$test";
}

路线

Route::post('updateC', ['uses' =>'RacesController@Points', 'as' => 'race.post']); 

还有我得到的错误.

控制台

网络预览

网络响应

推荐答案

我刚刚删除了url末尾的斜杠,它开始起作用.../managers/games/id/push/到:

I just removed the slash at the end of url and it began working... /managers/games/id/push/ to:

$http({
  method: 'POST',
  url: "/managers/games/id/push",

这篇关于Laravel错误405(不允许使用方法)Ajax发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆