post 500 (internal server error) ajax though using csrf token in laravel

天大地大妈咪最大 提交于 2020-01-17 14:35:14

问题


Though I am using {{ csrf_field() }} in my html file still got POST http://localhost:8000/add_user 500 (Internal Server Error)

here is my code

$.ajax({

    url:"/add_user",                       
    type: 'post',
    data: {_token : token, user_type_id : user_type_id,  full_name : full_name,  email : email, password : password,  username : username, date : date},
                        success:function(msg){

    $("#report").load(location.href + " #report");

   }
});

回答1:


you can do this with csrf token

$.ajax({
  type: "POST",
  url: "url/update",
  dataType: 'json',
  data: 'id=' + id+ '&_token={{csrf_token()}}',



回答2:


provide your server router, its seems like you`ve missed this route request on your server



来源:https://stackoverflow.com/questions/48185723/post-500-internal-server-error-ajax-though-using-csrf-token-in-laravel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!