Error 405 (Method Not Allowed) Laravel 5

前端 未结 6 808
遇见更好的自我
遇见更好的自我 2020-12-05 22:53

Im trying to do a POST request with jQuery but im getting a error 405 (Method Not Allowed), Im working with Laravel 5

THis is my code:

jQuery



        
6条回答
  •  余生分开走
    2020-12-05 23:29

    If you're using the resource routes, then in the HTML body of the form, you can use method_field helper like this:

    {{ csrf_field() }} {{ method_field('PUT') }}

    It will create hidden form input with method type, that is correctly interpereted by Laravel 5.5+.

    Since Laravel 5.6 you can use following Blade directives in the templates:

    @method('put') @csrf

    Hope this might help someone in the future.

提交回复
热议问题