if(type){
options = success
success = data;
data = {};
}
options = options || {};
return $.ajax({
type: options.type || 'post',
dataType: options.dataType || 'json',
data: data,
url: url,
success: function(res){
if(res.status === 0) {
success && success(res);
} else if(res.status === 2){ //未绑定手机号
that.setPhoneNotice();
} else if(res.status === 3){ //未激活邮箱
that.setEmailNotice();
} else {
layer.msg(res.msg || res.code, {shift: 6});
options.error && options.error();
}
}, error: function(e){
layer.msg('请求异常,请重试', {shift: 6});
options.error && options.error(e);
}
});
有几处写法不太理解,例如这种:options.type || 'post',这是什么用法,像三元又不像。中间一个或。
options.error && options.error(); 还有这种,他是啥意思。
js逻辑运算
JS中的||符号:
运算方法:
总结:真前假后
2、JS中的&&符号:
运算方法: