这是网页登陆部分的代码,点击登陆没有反应,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";
}
}
});
}
})
$("#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";
}
}
});
}
})
说明url写错误了
如果你的应用程序目录是 http://域名/应用程序名/api/loginCheck 当然就会404了