日期:2014-05-16  浏览次数:20695 次

AJAX菜鸟问个问题 - Web 开发 / Ajax
HTML code

<!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>
    <title>Page</title>
    <style type="text/css">
    .div
    {
        width:300px;
        height:30px;
        line-height:30px; 
        position:relative;
    }
    .div2
    {
        width:302px;
        height:auto;
        background-color:Green;
        position:absolute;
        top:30px;
        left:0px;    
    }
    .div2-line
    {
        width:302px;
        height:30px;
        line-height:30px;    
    }
    </style>
    <script type="text/javascript">
        function showHint(str) {
            var xmlhttp;
            if (str.length == 0) {
                document.getElementById("txtHint").innerHTML = "";
                return;
            }
            if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
                xmlhttp = new XMLHttpRequest();
            }
            else {// code for IE6, IE5
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            xmlhttp.onreadystatechange = function () {
                if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                    document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
                }
            }
            xmlhttp.open("GET", "http://localhost/1.asp?q=" + str, true);
            xmlhttp.send();
        }
    </script>
</head>
<body>
    <div class="div">
        <form action="">
        <input type="text" onkeyup="showHint(this.value)"  id="txt1" style="width:300px;height:22px;"/>
        </form>
        <div class="div2">
            <div class="div2-line" id="txtHint"></div>
        </div>
    </div>
</body>
</html>



VBScript code

<%
response.expires=-1
dim a(30)
'用名字来填充数组
a(1)="Anna"
a(2)="Brittany"
a(3)="Cinderella"
a(4)="Diana"
a(5)="Eva"
a(6)="Fiona"
a(7)="Gunda"
a(8)="Hege"
a(9)="Inga"
a(10)="Johanna"
a(11)="Kitty"
a(12)="Linda"
a(13)="Nina"
a(14)="Ophelia"
a(15)="Petunia"
a(16)="Amanda"
a(17)="Raquel"
a(18)="Cindy"
a(19)="Doris"
a(20)="Eve"
a(21)="Evita"
a(22)="Sunniva"
a(23)="Tove"
a(24)="Unni"
a(25)="Violet"
a(26)="Liza"
a(27)="Elizabeth"
a(28)="Ellen"
a(29)="Wenche"
a(30)="Vicky"

'获得来自 URL 的 q 参数
q=ucase(request.querystring("q"))

'如果 q 大于 0,则查找数组中的所有提示
if len(q)>0 then
  hint=""
  for i=1 to 30
    if q=ucase(mid(a(i),1,len(q))) then
      if hint="" then
        hint=a(i)
      else
        hint=hint & " , " & a(i)
      end if
    end if
  next
end if

'如果未找到提示,则输出 "no suggestion"
'否则输出正确的值
if hint="" then
  response.write("no suggestion")
else
  response.write(hint)
end if
%>




我一直不明白asp文件的路径该怎么写?要不要加http://localhost/,是不是要放在C:\Inetpub\wwwroot里面。。。

为什么在火狐下面有的时候提示 asp文件未组织好

------解决方案--------------------
第一个问题!取决你的IIS指向的文件夹!