要设置
dataType:"json", //返回格式为json
- $.ajax({
- url: "{:url('login')}",
- type: "post",
- dataType:"json", //返回格式为json
- async:true,//请求是否异步,默认为异步,这也是ajax重要特性
- data: {username:username,password:password,verifyCode:verifyCode},
- success: function(data) {
- layer.close(index);
- if(data['code'] == 200){
- layer.msg(data['msg'], {
- icon: 1,
- time: 2000 //2秒关闭(如果不配置,默认是3秒)
- }, function() {
- //window.location.href = data['url'];
- });
- }else{
- layer.msg(data['msg'], {
- icon: 1,
- time: 2000 //2秒关闭(如果不配置,默认是3秒)
- });
- }
- },
- error: function() {
- layer.msg('页面跳转失败!');
- }
- });



















