大家帮我看下这段代码的$.ajax()方法问题出在哪

tobemendax tobemendax 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
这是网页登陆部分的代码,点击登陆没有反应,f12看后台发现是/api/loginCheck这里报了404,显示$.ajax()这个方法有错,我不知道是方法写错了还是url这里有问题,哪位大神帮我看看啊啊啊……

setLoginStatus();
$("#loginButton").click(function () {
var id =$("#id").val();
var passwd=$("#passwd").val();
var remember=$("#remember").prop('checked');

if( id=='' && passwd==''){
$("#info").text("提示:账号和密码不能为空");
}
else if ( id ==''){
$("#info").text("提示:账号不能为空");
}
else if( passwd ==''){
$("#info").text("提示:密码不能为空");
}
else if(isNaN( id )){
$("#info").text("提示:账号必须为数字");
}
else {
$.ajax({
type: "POST",
url: "/api/loginCheck",
data: {
"id":id ,
"passwd": passwd
},
dataType: "json",
success: function(data) {
if(data.stateCode.trim() == "0") {
$("#info").text("提示:账号或密码错误!");
} else if(data.stateCode.trim() == "1") {
$("#info").text("提示:登陆成功,跳转中...");
window.location.href="/admin_main.html";
} else if(data.stateCode.trim() == "2"){
if(remember){
rememberLogin(id,passwd,remember);
}else {
Cookies.remove('loginStatus');
}
$("#info").text("提示:登陆成功,跳转中...");
window.location.href="/reader_main.html";


}
}
});
}
})
...全文

相关推荐

评论 5
收藏 已收藏
分享
返回顶部
tobemendax
JavaScript 87,984 成员 224,681 内容