Skip to content

Instantly share code, notes, and snippets.

@xiaoysh8
Created July 17, 2018 02:29
Show Gist options
  • Save xiaoysh8/bac9b5792a991f4d752e62de9387b5d0 to your computer and use it in GitHub Desktop.
Save xiaoysh8/bac9b5792a991f4d752e62de9387b5d0 to your computer and use it in GitHub Desktop.
ajax object message
<script>
var _token = '{{csrf_token()}}';
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': _token
}
});
</script>
接下来就可以把错误信息提取出来了。
sendMsg:function(url,mobile,captcha)
{
$.ajax({
url:url,
data:{mobile:mobile,captcha:captcha,token:_token},
type:'post',
timeout : 5000,
cache:false,
async:true,
success:function(d){
return true;
},
error : function (msg ) {
var json=JSON.parse(msg.responseText);
$.each(json.errors, function(idx, obj) {
alert(obj[0]);
return false;
});
},
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment