前端 422 代码不理解?
能否详细的讲解一下这段代码?谢谢了
else if (error.response.status === 422) {
// http 状态码为 422 代表用户输入校验失败
var html = '
';
.each(error.response.data.errors, function (errors) {
.each(errors, function (error) {
html += error+'
';
})
});
html += '
.each(error.response.data.errors, function (errors) {
.each(errors, function (error) {
html += error+'
';
})
});
html += '
';
swal({content: $(html)[0], icon: 'error'})
}
关于 LearnKu
通过 Ajax 请求的接口,validate 如果校验失败就会返回 422 状态码。