欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

each 有大用


$.ajax({
type: 'POST',
async:false,
url: '/front/ajax-order',
data: $("#orderform").serialize(),
dataType: 'json',
headers: {
'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
},
success: function(data){
if(data.status == '0'){
alert('有错误!');
}
},
error: function(jqXhr, textStatus){
if( jqXhr.status === 401 ) {
alert('无权操作');
}
if( jqXhr.status === 422 ) {
var errors = jqXhr.responseJSON;
console.log(errors);
var errStr = '';
$.each( errors , function( key, value ) {
               console.log(key);
               console.log(value);
               errStr += value[0];
           });

alert(errStr);
}else{
alert('有错语!')
}
return false;

}
});

image.png

value[0] 就是值了

image.png

普通分类: