后端接值验证
$data = $request->validate([
'username' => 'required',
'password' => 'required',
'captcha' => 'required|captcha'
],[
'username.required' => '用户名不能为空',
'password.required' => '密码不能为空',
'captcha.required' => '验证码不能为空',
'captcha.captcha' => '验证码不正确',
]);
前端ajax使用错误回调
$.ajax({
url:"{
{route('test.login')}}",
type:'POST',
data:{
username:username,
password:password,
captcha:captcha,
_token:"{
{csrf_token()}}"
},
success:function (res){