不是经常发生的问题 十次有俩次
账号 密码 验证码 都输入无误 点击登陆按钮 没有登入 登陆页面刷了一下
再次输入账号 密码 验证码 就能正常登入
$().ready(function () {
if ($('#username').val() == "")
$('#username').focus();
else
$('#password').focus();
$('#Login').click(function () {
if ($('#username').val() == "") {
document.form1.username.focus();
alert("账号不能为空!");
return false;
}
else if ($('#password').val() == "") {
document.form1.password.focus();
alert("密码不能为空!");
return false;
}
else if ($('#chktxt').val() == "") {
document.form1.chktxt.focus();
alert("验证码不能为空!");
return false;
}
else if ($('#chktxt').val().toLowerCase() != $('#Hidden1').val().toLowerCase()) {
document.form1.chktxt.focus();
document.form1.chktxt.select();
alert("验证码输入错误!");
return false;
}
else {
$.ajax({
type: "POST",
url: "ajax/login.ashx",
data: "username=" + escape($('#username').val()) + "&password=" + escape($('#password').val()) + "&chktxt=" + escape($('#chktxt').val()),
success: function (msg) {
if (msg == "success") {
window.location = "index.html";
}
if (msg == "fail") {
alert('帐号或密码错误!!!');
return false;
}
},
error: function (XMLHttpRequest, textStatus, thrownError) {
}
});
}
});
});
11 个解决方案
#1
window.location = "index.html";
==>
alert("成功登陆...");
location.href="index.html";
==>
alert("成功登陆...");
location.href="index.html";
#2
可为什么十次里有八次是正常第一次点击登陆按钮就能正常登入呢?
#3
你先确定能不能进入到这里先
#4
可为什么十次里有八次是正常第一次点击登陆按钮就能正常登入呢?
window.location = "index.html";
==>
alert("成功登陆...");
location.href="index.html";
你先确定能不能进入到这里先
#5
document.form1.chktxt.focus();
document.form1.chktxt.select();
估计这种语法有错
document.form1.chktxt.select();
估计这种语法有错
#6
document.form1.chktxt.focus();
document.form1.chktxt.select();
估计这种语法有错
#7
document.form1.chktxt.focus();
document.form1.chktxt.select();
估计这种语法有错
#8
alert("账号不能为空!");
$('#username').focus();
return false;
一般执行的顺序是这样
$('#username').focus();
return false;
一般执行的顺序是这样
#9
lz要搞哪样啊,一会jquery一会原生的js
#10
是不是可能文档没加载完成, 你试下慢点点击登录。 是不是每次都能够成功?
#11
你把ajax error里面加个alert试试,有可能登陆后台不成功呢
#1
window.location = "index.html";
==>
alert("成功登陆...");
location.href="index.html";
==>
alert("成功登陆...");
location.href="index.html";
#2
window.location = "index.html";
==>
alert("成功登陆...");
location.href="index.html";
#3
可为什么十次里有八次是正常第一次点击登陆按钮就能正常登入呢?
window.location = "index.html";
==>
alert("成功登陆...");
location.href="index.html";
你先确定能不能进入到这里先
#4
可为什么十次里有八次是正常第一次点击登陆按钮就能正常登入呢?
window.location = "index.html";
==>
alert("成功登陆...");
location.href="index.html";
你先确定能不能进入到这里先
#5
document.form1.chktxt.focus();
document.form1.chktxt.select();
估计这种语法有错
document.form1.chktxt.select();
估计这种语法有错
#6
document.form1.chktxt.focus();
document.form1.chktxt.select();
估计这种语法有错
#7
document.form1.chktxt.focus();
document.form1.chktxt.select();
估计这种语法有错
#8
alert("账号不能为空!");
$('#username').focus();
return false;
一般执行的顺序是这样
$('#username').focus();
return false;
一般执行的顺序是这样
#9
lz要搞哪样啊,一会jquery一会原生的js
#10
是不是可能文档没加载完成, 你试下慢点点击登录。 是不是每次都能够成功?
#11
你把ajax error里面加个alert试试,有可能登陆后台不成功呢