$.ajax({
url : "http://localhost:8080/user/login", //请求地址
dataType : "json", //返回数据格式
async : true , //是不是异步请求 默认异步
data : {username:username,password:password}, //参数传递
type : "post", //请求方式
success:function (res){
// 请i去成功时的操作
console.log(res);
if (res.code ==10000){
//登陆成功 跳转index
window.location.href="index.html";
}else {
//登陆失败
$("#tips").html("<label style='color:#c687da'>"+res.msg+"</label>");
}
}
}
)
Ajax基本格式
最新推荐文章于 2023-04-02 21:31:51 发布