首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Ajax >

ajax+asp+access在登记页面时显示不出用户名是否存在。

2013-03-28 
ajax+asp+access在注册页面时显示不出用户名是否存在。。急第一个页面user.asp%@LANGUAGEVBSCRIPT CODEP

ajax+asp+access在注册页面时显示不出用户名是否存在。。急
第一个页面user.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
.aa{ visibility:}
</style>
</head>
<script language="javascript" type="text/javascript">
 var xmlHttp;
function creatXMLHttpRequest()
 { 
 try
    {
   // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
 catch (e)
    {
  // Internet Explorer
   try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
   catch (e)
      {

      try
         {
         xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
         }
      catch (e)
         {
         alert("您的浏览器不支持AJAX!");
         return false;
         }
      }
    }
 }

function staratrequest()
{
var str=document.getElementById("username").value;
var url="ajaxuser.asp?times="+encodeURI(str)+"&aa="+new Date().getTime();
creatXMLHttpRequest();
xmlHttp.onreadystatechange=handstartchange;
xmlHttp.open("get",url,true);
xmlHttp.send(null);
}
function handstartchange()
{
var div1=document.getElementById("divuser");
var bot=document.getElementById("button");
if(xmlHttp.readyState==4)
{
if(xmlHttp.status==200)
{
if(xmlHttp.responseText=="nono"){
div1.innerHTML="<img src='images/error.jpg' width='16' height='18' />用户名不能为空!" ;
bot.disabled=true;
return false;
}
else
{
if(xmlHttp.responseText=="no")
{
div1.innerHTML="<img src='images/error.jpg' width='16' height='18' />用户名已经被占用!" ;
bot.disabled=true;
return false;
}
else
{
div1.innerHTML="<img src='images/right.jpg' width='16' height='18' />用户可以注册!" ;
return true;
}
}
}
}
}
function fous()
{
var div1=document.getElementById("divuser");
div1.innerHTML="" ;
document.getElementById("button").disabled=false;
}
</script>
<body>
<form name="form1" action="insert.asp" method="post">
<table width="463" border="1">
  <tr>
    <td width="80">用户名</td>
    <td width="168"><label>
      <input type="text" name="username" id="username"  onfocus="fous();" onblur="staratrequest();" />
    </label></td>


    <td width="193"><div id="divuser"></div></td>
  </tr>
  <tr>
    <td>密码</td>
    <td><label>
      <input type="text" name="password" id="password" />
    </label></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><label>
      <input type="submit" name="button" id="button" value="提交"  />
      <input type="reset" name="button2" id="button2" value="重置" />
    </label></td>
    <td>&nbsp;</td>
  </tr>
</table>
</form>
</body>
</html>



第二个页面,连接数据库
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
Set Conn=Server.CreateObject("ADODB.Connection")
connstr="provider=microsoft.jet.oledb.4.0;Data source="&Server.MapPath("database/DB.mdb")
%>



第三个页面
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!-- #include file="conn.asp" -->
<%
user=request.QueryString("times")
if user="" then
%>
<%response.Write"nono"%>
<%else%>
<%
Set Conn=Server.CreateObject("ADODB.Connection")
Set st=Server.CreateObject("ADODB.Connection")
conn.open constr
sql="select name from loginmima where name='"& user & "'"
set rs=conn.execute(sql,,adcmdtext)
if not rs.eof then
%>
<%
response.write "no"
response.end
%>
<%else%>
<%response.write "ok"
response.end
%>
<%end if
%>
<%end if
%>


ajax asp access vbscript
[解决办法]
本帖最后由 showbo 于 2013-03-07 11:17:45 编辑 Page指令重复导致出错了

第二个页面,连接数据库
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
Set Conn=Server.CreateObject("ADODB.Connection")
connstr="provider=microsoft.jet.oledb.4.0;Data source="&Server.MapPath("database/DB.mdb")
%>

删掉红色的部分 


先直接访问asp文件把错误全部更正后再用ajax请求,要不出问题不会调试比较难找错误
[解决办法]
调调试试一直想学ajax

热点排行