douhuzhi0907 2017-08-31 14:22
浏览 69
已采纳

ajax没有调用控制器函数laravel

I am using following code in javascript function

 $.ajax({
    type: "DELETE",
    url: '/delprofile',
    success:alert("Record deleted."),
        error:  alert("Record not deleted.")
});

and my route and function are as :

public function delprofile (Request $request){  
   DB::table('education')->where('id','=',7)->delete();
   return true;
}

Route::post('/delprofile','ProfileController@delprofile');

The query is not performing any deletion.

  • 写回答

3条回答 默认 最新

  • doubanduo7620 2017-09-05 06:50
    关注

    added CSRF token in ajax code

    data: {'_token': $('meta[name="csrf-token"]').attr('content')
                },
    

    Discussed here

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?