首页 > 其他分享 >常用jQuery ajax代码片段

常用jQuery ajax代码片段

时间:2022-12-22 16:07:04浏览次数:38  
标签:jQuery case 片段 console log break ajax 请求


 

 

$.ajax({
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);
}
});

标签:jQuery,case,片段,console,log,break,ajax,请求
From: https://blog.51cto.com/u_15920212/5962965

相关文章