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

ajax中请求的文档的url写法问题
文档一
<script language="text/javascript">
var xmlHttp

function showHint(str)
{
 xmlHttp=GetXmlHttpObject()//创建xmlHttp实例对象的的函数被我省略了
 var url="gethint.jsp";
 url=url+"?q="+str;
 url=url+"&sid="+Math.random();//1
 xmlHttp.onreadystatechange=stateChanged;
 xmlHttp.open("GET",url,true);
 xmlHttp.send(null);

function stateChanged() 

 if (xmlHttp.readyState==4)
 { 
  document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
  }
}
</script>
</head>
<body>
<form> 
First Name:<input type="text" id="txt1" onkeyup="showHint(this.value)" />
</form>
<p>Suggestions: <span id="txtHint"></span></p> 
</body>
</html>
----------------------------------------
文档gethint.jsp
<%
response.expires=-1
dim a(5)
a(0)="Jack"
a(1)="Anna"
a(2)="Brittany"
a(3)="Cinderella"
a(4)="Diana"
a(5)="Eva"
q=ucase(request.querystring("q"))
if len(q)>0 then
  hint=""
  for i=0 to 5
  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
if hint="" then 
  response.write("no suggestion")
else
  response.write(hint)
end if
%>

上面是一个通过ajax进行异步通信,文档一中我省略了一些代码,所请求的页面gethint.jsp是用vbscript完成的,文档一中//1这一句是什么意思??

------解决方案--------------------
探讨

不是response.expires=-1这一句,url=url+"&amp;sid="+Math.random()是什么意思??文档gethint.jsp中hint=hint &amp; " , " &amp; a(i)是什么意思??