【问题标题】:laravel - Ajax Post says NotFoundHttpExceptionlaravel - Ajax Post 说 NotFoundHttpException
【发布时间】:2015-09-02 11:48:09
【问题描述】:

我是 laravel 的新手。最近我从 github 克隆了示例项目。我尝试做凝乳手术。当我发布我得到的数据时

{"error":"type":"Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException","message":"","file":"\/home\/sq1\/lampstack-5.5.28\/apache2\/htdocs\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/RouteCollection.php","line":145}}

Routes.php

Route::group
(
    [
        'prefix'    => '/executive/ajax',
    ],
    function ()
    {
        Route::get
        (
            'get-executive',
            'LeadExecutiveController@getLeadExecutives'
        );
        Route::get
        (
            'get-executive/{sponsorID}',
            'LeadExecutiveController@getLeadExecutiveData'
        );
);
Route::resource('/executive' ,'ExecutiveController');

ExecutiveController.php

public function store() //I think store action should work here
{
 ...
}
public function destroy($id)
{
 ...
}
public function getLeadExecutiveData($leadExecutiveID)
{
 ...
}
public function update($leadExecutiveID)
{
 ...
}

Ajax 网址http://localhost:8080/app/public/deal/executive

帖子参数:

_token  : WXv5u4zYkANnnWidTciFN8HVrz2ARECe669Kwvqn
first_name : test
last_name  : test

【问题讨论】:

  • 我认为您的 Url 构建不正确...您是如何做到的?

标签: php symfony laravel laravel-5


【解决方案1】:

您发布到deal/executive,但您的资源设置为executive。 将您的路由器更改为:

Route::resource('deal/executive' ,'ExecutiveController');

【讨论】:

  • 记得运行:php artisan route:cache
猜你喜欢
  • 2019-03-12
  • 2016-12-02
  • 1970-01-01
  • 1970-01-01
  • 2021-07-09
  • 2017-01-23
  • 2015-01-11
  • 2013-08-17
  • 2015-03-03
相关资源
最近更新 更多