Reputation: 588
I'm working on a Laravel 5.2.10 project, I was trying to fetch some data via ajax but I'm getting an 500 error, and I can't find what I'm missing out.
This is part of my 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');
});
On my 'AjaxController.php' I've got this function
public function postFetch()
{
//Process data and come up with $data
return view('videos')->with('video_data', $data);
}
And this is the JS ajax call
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
Upvotes: 1
Views: 432
Reputation: 10533
The MethodNotAllowed
exception hints that your post route isn't being picked up. The format of your post route looks a little odd to me. It should be in the following format
Route::post('videos/fetch', array( 'before' => 'ajax_check', 'uses' => 'AjaxController@postFetch' ));
Upvotes: 2
Reputation: 1245
Have you set permissions on your storage folder ? Please check your internal php server errors for more info with the command:
tail /var/log/php_errors.log
Upvotes: 0