Ajax模板

index.html:

 

  1. <html>
  2. <head>
  3. <title>AJAX教程实例-AJAX教程实例-ASP+AJAX</title>
  4. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  5. </head>
  6. <body>
  7. <script>
  8. var xmlHttp
  9. function showCustomer(str)
  10. var url="getcustomer.asp?sid=" + Math.random() + "&q=" + str
  11. xmlHttp=GetXmlHttpObject(stateChanged)
  12. xmlHttp.open("GET", url , true)
  13. xmlHttp.send(null)
  14. function stateChanged() 
  15. if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  16. document.getElementById("txtHint").innerHTML=xmlHttp.responseText 
  17. function GetXmlHttpObject(handler)
  18. var objXmlHttp=null
  19. if (navigator.userAgent.indexOf("Opera")>=0)
  20. {
  21. alert("This example doesn't work in Opera") 
  22. return; 
  23. }
  24. if (navigator.userAgent.indexOf("MSIE")>=0)
  25. var strName="Msxml2.XMLHTTP"
  26. if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
  27. {
  28. strName="Microsoft.XMLHTTP"
  29. try
  30. objXmlHttp=new ActiveXObject(strName)
  31. objXmlHttp.onreadystatechange=handler 
  32. return objXmlHttp
  33. catch(e)
  34. alert("Error. Scripting for ActiveX might be disabled") 
  35. return 
  36. if (navigator.userAgent.indexOf("Mozilla")>=0)
  37. {
  38. objXmlHttp=new XMLHttpRequest()
  39. objXmlHttp.onload=handler
  40. objXmlHttp.onerror=handler 
  41. return objXmlHttp
  42. }
  43. </script>
  44. <form>请选择用户:
  45. <select name="customers" onchange="showCustomer(this.value)">
  46. <option value="1">阿里西西</option>
  47. <option value="2">哇塞网</option>
  48. <option value="3">收音机</option>
  49. </select>
  50. </form><p>
  51. <div id="txtHint"><b>用户信息...</b></div>
  52. </p></body>
  53. </html>

getcustomer.asp:

 

 

  1. <ul>
  2. <%
  3. response.write "<li>12312312</li>"
  4. response.write "<li>123</li>"
  5. response.write "<li>123123</li>"
  6. %>
  7. </ul>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值