lundi 22 février 2016

Can not post in laravel 5 over jquery Ajax

I'm trying to send a POST request over jquery Ajax in Laravel 5.1 application. I got 405 method not allow, I'm search other questions on this forum but not find solution:

My routes.php:

Route::post('backend/get_subdirectories',  'Backend\FileManagerController@get_subdirectories');

The Controller

public function get_subdirectories(Request $request)
{
    dd($request);
}

And script

var _token = $('meta[name="csrf-token"]').attr('content');
console.log(_token); //It work, I can get my token from meta tag
$.post(
            'http://ift.tt/1QcXt0m',
            { _token: _token},
            function () {
                alert("success");
            })
            .fail(function () {
                alert("error");
            })
            .always(function () {
                alert("finished");
            });

And I got error 405 - Method not allowed

What am I wrong ?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/20RpRGW
via IFTTT

Aucun commentaire:

Enregistrer un commentaire