【发布时间】:2018-06-19 12:33:15
【问题描述】:
虽然我在我的 html 文件中使用{{ csrf_field() }} 仍然得到POST http://localhost:8000/add_user 500 (Internal Server Error)
这是我的代码
$.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");
}
});
【问题讨论】:
-
你从哪里得到你的令牌?使用 ajax(而不是 AXIOS)时,您需要在 javascript 中包含类似
var csrf_token = $('meta[name="csrf-token"]').attr('content');的内容 -
@kerbholz...我已将
{{ csrf_field() }}添加到我的表单中 -
你的表单在使用 ajax 时没有被提交
-
@ kerbholz....我已经使用相同类型的 ajax 函数完成了删除和更新部分。但是在添加部分显示了这个错误......它没有提交我得到了那个兄弟。但是我想知道的错误在哪里:(
标签: php jquery ajax laravel-5.3