ajax post in laravel 5 return error 500 (Internal Server Error)

后端 未结 12 1046
不知归路
不知归路 2020-11-29 05:13

this is my test ajax in laravel 5 (refer below)

$(\"#try\").click(function(){
    var url = $(this).attr(\"data-link\");
    $.ajax({
        url: \"test\",
         


        
12条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-29 05:56

    for me this error cause of different stuff. i have two ajax call in my page. first one for save comment and another one for save like. in my routes.php i had this:

    Route::post('posts/show','PostController@save_comment');
    Route::post('posts/show','PostController@save_like');
    

    and i got 500 internal server error for my save like ajax call. so i change second line http request type to PUT and error goes away. you can use PATCH too. maybe it helps.

提交回复
热议问题