$.ajax({标签:jQuery,case,片段,console,log,break,ajax,请求 From: https://blog.51cto.com/u_15920212/5962965
type: "POST",
url: "http://127.0.0.1:9999/api/demo/CURD",
data: JSON.stringify({
token: "sgToken",
jsonPath: "user",
username: "测试账号",
password: "123456",
name: "测试人员",
role: "teacher"
}),
headers: {"Content-Type": "application/json"},
success: d => {
switch (d.code) {
case 0:
console.log("请求成功", d);
break;
case -404:
console.log("跳转到登录页面", d);
break;
case -1:
default:
console.log("获取失败", d);
break;
}
}, error: d => {
console.log("请求报错", d);
}
});