Laravel 5.1 POST with ajax, get error. Do it with GET and it’s work

So it’s my first laravel project and i can’t find out what’s the problem.

I searched for hours, but nothing helped.

{!! csrf_field() !!} is in my form, the _token data is sended

Route:

Route::post('/posts/create', [
    'middleware' => 'auth',
    "as" => 'post-create',
    "uses"=>'PostsController@create'
]);

Ajax:

 $.ajax({
     url:'{{route('post-create')}}',
     type:'POST',
     data:form.serialize()
 });

And the laravel standard user register doesn’t work too. When the login does (both works with post).

What did i miss?


Source: php

Leave a Reply