Created
July 17, 2018 02:29
-
-
Save xiaoysh8/bac9b5792a991f4d752e62de9387b5d0 to your computer and use it in GitHub Desktop.
ajax object message
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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