yms123可以进来帮忙一下吗AJAX问题
这个是验证的的代码问题是这样的xmlHttp.responseText返回来的值,如果是中文是乱码,,是英文不会乱,,这是怎么回事
还有就算是英文返来的值,也不可以作比较,,,如这个代码
var hj=xmlHttp.responseText
//hj=parseInt(hj)
document.all.goo.innerHTML=hj
var gh=document.all.goo.innerHTML
if(hj=="ok"){
document.all.gooh.innerHTML="你可以注册"
}
else
{ document.all.gooh.innerHTML="你不可以注册"}
}
详细代码:
页面index.html
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script language="javascript">
var xmlHttp;
try{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
xmlHttp = new XMLHttpRequest();
}
function callback(){
if(xmlHttp.readyState == 4){
if(xmlHttp.status == 200){
var ol="ok"
var hj=xmlHttp.responseText
//hj=parseInt(hj)
document.all.goo.innerHTML=hj
var gh=document.all.goo.innerHTML
if(hj=="ok"){
document.all.gooh.innerHTML="你可以注册"
}
else
{ document.all.gooh.innerHTML="你不可以注册"}
}
}
}
function UsName_Blur()
{
// loadHTTP();
//xmlHttp.ResponseType="Text";
// ActionControl="IsUserHave";
xmlHttp.open("get","goog.asp?Action=IsUserHave&UserName="+this.username.value);
//xmlHttp.setrequestheader("contentType","text/html;charset=GB2312")//
xmlHttp.onreadystatechange=callback;
xmlHttp.send(null);
}
</script>
<body>
<table width="407" height="82" border="1">
<tr>
<td width="35">用户</td>
<td width="168">
<input type="text" name="username" onblur="UsName_Blur();" />
</td>
<td width="182"><input type="text" name="goog" /></td>
</tr>
<tr>
<td>?</td>
<td><div id="goo"></div></td>
<td><div id="gooh"></div></td>
</tr>
</table>
</body>
</html>
页面
goog.asp的代码
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<%conn="driver={microsoft access driver (*.mdb)};dbq="&server.MapPath("df.mdb")
set rs=server.CreateObject("adodb.recordset")
if request.QueryString("username")<>"" then
sql="select * from rnameH where rname='"&request.QueryString("username")&"'"
rs.open sql,conn,1,1
if rs.eof then
message="ok"
else
message="not"
end if
end if
response.write message
%>
</body>
</html>
[[italic] 本帖最后由 willam 于 2008-1-3 12:05 编辑 [/italic]]