function ajaxUpdate() {
$(".error").text("");
var username = $("#username").val();
var nickname = $("#nickname").val();
var sex = $("input[type='radio']").val()
var birthday = $("#birthday").val();
var mobile = $("#mobile").val();
var emil = $("#emil").val();
var card = $("#card").val();
var headerimg = $("#imageUrl").val();
if (username == null) {
$("#error").text("真实用户名不能为空").css("color", "red");
return false;
} else if (nickname == null) {
$("#error2").text("昵称不能为空").css("color", "red");
return false;
} else if (birthday == null) {
$("#error4").text("生日不能为空").css("color", "red");
return false;
} else if (emil == null) {
$("#error6").text("邮箱不能为空").css("color", "red");
return false;
}
if (card == null) {
$("#error7").text("银行卡号不能为空").css("color", "red");
return false;
}
$(".error").text("");
$.ajax({
url: baseUrl + "/api/user",
type: "post",
data: {
"method": "updateUser",
"mobile": mobile,
"username": username,
"nickname": nickname,
"sex": sex,
"birthday": birthday,
"card": card,
"email": emil,
"headerimg": headerimg
},
dataType: "json",
success: function (data) {
console.log(data)
if (data.code == 1) {
layer.msg(data.msg);
} else {
layer.msg(data.msg);
}
},
error: function (e) {
}
})
}
ajax封装传递数据
最新推荐文章于 2023-01-18 11:17:38 发布