9***@qq.com
9***@qq.com
  • 发布:2018-09-13 14:21
  • 更新:2018-09-13 16:45
  • 阅读:1105

求问ajax中,json的这个方法是啥意思

分类:HBuilder

求问代码中的 result.returnvalue是干啥,这是别人做的一个登陆的代码,求分析下,谢谢

mui.ajax('127.0.0.1/pr1', {  
        data: {  
            'username': username,  
            'password': password  
        },  
        crossDomain: true,  
        headers: {  
            'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'  
        },  
        type: 'post', //HTTP请求类型  
        timeout: 10000, //超时时间设置为10秒;  
        success: function(data) {  
            var result = JSON.parse(data);  
            if(result.returnvalue == '1') {  
                console.log(JSON.stringify(result));  
                UserData.SetUserData(data,function(){  
                    LoginController.GotoIndex();  
                    PermissionsData.GetPermissions();  
                });  
            }else{  
                mui.toast(JSON.stringify(result.message),{ duration:'long', type:'div' });  
            }  
        },  
        error: function(xhr, type, errorThrown) {  
            mui.alert("请求错误。" + errorThrown + "状态:" + type);  
        }  
    });
2018-09-13 14:21 负责人:无 分享
已邀请:
冰凌桦

冰凌桦

接口返回结果:returnvalue == '1'表示成功,其他为失败;这是接口自己定义的,可以为其他值。

  • 9***@qq.com (作者)

    嗯,找到了,是返回值json中的一个key,谢谢

    2018-09-13 17:19

该问题目前已经被锁定, 无法添加新回复