Error 405 (Method Not Allowed) Laravel 5

前端 未结 6 799
遇见更好的自我
遇见更好的自我 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:22

    Your routes.php file needs to be setup correctly.

    What I am assuming your current setup is like:

    Route::post('/empresas/eliminar/{id}','CompanyController@companiesDelete');
    

    or something. Define a route for the delete method instead.

    Route::delete('/empresas/eliminar/{id}','CompanyController@companiesDelete');
    

    Now if you are using a Route resource, the default route name to be used for the 'DELETE' method is .destroy. Define your delete logic in that function instead.

提交回复
热议问题