save.js
2.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
$(document).ready(function() {
$(".btnSave a").click(function() {
//姓
var inputSurname = $("#surname").val();
console.log(inputSurname);
//名
var inputUserName = $("#userName").val();
console.log(inputUserName);
//专业(null)
var inputSpecialty = $("#specialty").val();
console.log(inputSpecialty);
//学校
var inputSchool = $("#school").val();
console.log(inputSchool);
//手机号
var inputPhone = $("#phone").val();
console.log(inputPhone);
//邮箱
var inputEmailAddress = $("#emailAddress").val();
console.log(inputEmailAddress);
if (inputSurname.length === 0) {
alert("姓氏不能为空!")
} else if (inputUserName.length === 0) {
alert("名字不能为空!")
} else if (inputSchool.length === 0) {
alert("学校不能为空!")
} else if (inputPhone.length === 0) {
alert("手机号码不能为空!")
} else if (inputEmailAddress.length === 0) {
alert("邮箱不能为空!")
} else {
$.ajax({
type: "PUT",
url: "http://192.168.1.241:9004/login/updateSysUser",
// dataType: "jsonp",
headers: {
"Content-Type": "application/json"
},
data: JSON.stringify({
emailAddress: inputEmailAddress,
id: localStorage.getItem("userId"),
img: null,
phone: inputPhone,
specialty: inputSpecialty,
school: inputSchool,
surname: inputSurname,
userName: inputUserName
}),
success: function(msg) {
alert('保存成功!')
window.location.href = 'index.html'
},
error: function(res) {}
});
}
})
});