Laravel 5.2.10 项目的内部服务器错误 Ajax 请求

Internal Server Error Ajax request on Laravel 5.2.10 project

我正在做一个 Laravel 5.2.10 项目,我试图通过 ajax 获取一些数据,但我收到了 500 错误,而且我找不到我在做什么错过了。

这是我的一部分 routes.php

Route::group(['middleware' => 'web'], function () {
    Route::auth();
    Route::get('/home', 'HomeController@index');
    Route::get('/videos', 'VideosController@index');
    Route::post('/videos/fetch', array('before' => 'ajax_check'), 'AjaxController@postFetch');
});

在我的 'AjaxController.php' 我有这个功能

public function postFetch()
{
    //Process data and come up with $data
    return view('videos')->with('video_data', $data);
}

这是 JS ajax 调用

var request = $.ajax({
    url: "/videos/fetch",
    method: "POST",
    data: { url : url }
});

request.fail(function( jqXHR, textStatus ) {
    alert( "Request failed: " + textStatus );
});

MethodNotAllowedHttpException in RouteCollection.php line 219: in RouteCollection.php line 219 at RouteCollection->methodNotAllowed(array('POST')) in RouteCollection.php line 206 at RouteCollection->getRouteForMethods(object(Request), array('POST')) in RouteCollection.php line 158

您是否设置了存储文件夹的权限?请使用以下命令检查您的内部 php 服务器错误以获取更多信息:

tail /var/log/php_errors.log

MethodNotAllowed 异常提示您的 post 路线未被接收。你的 post 路线的格式对我来说有点奇怪。它应该采用以下格式

Route::post('videos/fetch', array( 'before' => 'ajax_check', 'uses' => 'AjaxController@postFetch' ));