这是FORM表单<form name="form" method="post" onsubmit="return userOpenLogin(form)" action="/?C=login"></form>
JS中:
$.post(domain_name + '/?C=checkUserLoginAjax&user_password=' + user_password +'&user_name='+encodeURIComponent(user_name), function(data){
if(data == 0){
$("#texttishi").html('登录名或密码错误!');
return false;
}else{
$("#texttishi").html('输入正确!');
}
});
这样一来,每次不管是输入正确还是错误他都会跳转到登录页。我现在想让错误的时候停留,可以吗?
JS中:
$.post(domain_name + '/?C=checkUserLoginAjax&user_password=' + user_password +'&user_name='+encodeURIComponent(user_name), function(data){
if(data == 0){
$("#texttishi").html('登录名或密码错误!');
return false;
}else{
$("#texttishi").html('输入正确!');
}
});
这样一来,每次不管是输入正确还是错误他都会跳转到登录页。我现在想让错误的时候停留,可以吗?
return false;
$("#texttishi").html('登录名或密码错误!');
}这样试试
不知道你明白没有?呵呵,给你个例子<input type="text" name="name" id="name" />
<input type="text" name="password" id="password" />
<input type="button" value="登陆" onclick="return login()" />
js中:
function login()
{
$.post(domain_name + '/?C=checkUserLoginAjax&user_password=' + user_password +'&user_name='+encodeURIComponent(user_name), function(data){
if(data == 0){
$("#texttishi").html('登录名或密码错误!');
return false;
}else{
$("#texttishi").html('输入正确!');
return true;
}
});}
写的是伪代码哈,具体是这个意思
userOpenLogin()
这个函数的原形及这个原形是否有返回true或者flase