dqq22391
2017-01-16 18:13
浏览 272

Laravel ajax 405方法不允许

Upon form submission I run this ajax:

$gradeID=$('#GradeID').val();
$.ajax({
    method: "POST",
    url: "grades/ajaxprice",
    data: { gradeID: $gradeID}
})
.done(function( msg ) {
    alert( "Data Saved: " + msg );
});

In my controller I have this:

public function getgradeprice()
{
    // $gradeID = Input::get('gradeID');
    // dd($gradeID);
}

Here is the route:

Route::get('grades/ajaxprice', 'GradesController@ajaxGradePrice');

But then I am getting this error:

405 Method Not Allowed.

What could be wrong?

图片转代码服务由CSDN问答提供 功能建议

在提交表单后,我运行此ajax:

  $ gradeID  = $('#GradeID')。val(); 
 $ .ajax({
 method:“POST”,
 url:“grades / ajaxprice”,
 data:{gradeID:$ gradeID} 
  })
.done(function(msg){
 alert(“Data Saved:”+ msg); 
}); 
   
 
 

在我的控制器中 我有这个:

  public function getgradeprice()
 {
 // $ gradeID = Input :: get('gradeID'); 
 // dd($  gradeID); 
} 
   
 
 

以下是路线:

  Route :: get('grades /  ajaxprice','GradesController @ ajaxGradePrice'); 
   
 
 

但后来我收到此错误:

405方法不允许。

可能出错?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • donglin9717 2017-01-16 19:01
    已采纳

    I think the name of the method could be wrong:

    You have: Route::post('grades/ajaxprice', 'GradesController@ajaxGradePrice');

    It must be: Route::post('grades/ajaxprice', 'GradesController@getgradeprice');

    打赏 评论

相关推荐 更多相似问题