ajax判断是小 - Web 开发 / Ajax
我判断一个邮箱是否注册,无论输入什么邮箱都提示已注册,郁闷很。很焦急。
ajax.js
function send0()
{
createxmlrequesthttp();
var useremail=document.getElementById("uesremail").value;
var ch=document.getElementById("useremail_info");
xmlhttp.open("get","find.asp?useremail0="+ escape(useremail) +"&t=" + new Date().getTime());
xmlhttp.onreadystatechange=function()
{
if(4==xmlhttp.readyState)
{
if(200==xmlhttp.status)
{
if (xmlhttp.responseText=="yes")
{
msg="ok";
}
else
{
msg="不存在此邮箱,请重新输入";
}
}
else
{
msg="网络链接失败";
}
var ch=document.getElementById("useremail_info");
ch.innerHTML="<font color='#ff0000'>"+msg+"</font>";
}
}
xmlhttp.send(null);
return false;
}
find.asp
<%
dim useremail
useremail=request("useremail0")
set rs=server.createobject("adodb.recordset")
rs.open "select * from [member] where [useremail]='" & useremail & "'",conn,1,1
if rs.eof then
response.write "no"
else
response.write "yes"
end if
rs.close
set rs=nothing
set conn=nothing '清空对象
%>
------解决方案--------------------
看下select * from [member] where [useremail]='" & useremail & "'"这个查询是不是对的。返回的什么值。然后再看下xmlhttp.responseText 的值。
------解决方案--------------------
试一下
JScript code
function send0()
{
createxmlrequesthttp();
var useremail=document.getElementById("uesremail").value;
var ch=document.getElementById("useremail_info");
xmlhttp.open("get","find.asp?useremail0="+ escape(useremail) +"&t=" + new Date().getTime());
xmlhttp.send(null);
xmlhttp.onreadystatechange=function()
{
if(4==xmlhttp.readyState)
{
if(200==xmlhttp.status)
{
if (xmlhttp.responseText=="yes")
{
msg="ok";
}
else
{
msg="不存在此邮箱,请重新输入";
}
}
else
{
msg="网络链接失败";
}
var ch=document.getElementById("useremail_info");
ch.innerHTML=" <font color='#ff0000'>"+msg+" </font>";
}
}
return false;
}