读书人

asp无刷新读取数据!该怎么处理

发布时间: 2012-09-13 09:51:52 作者: rapoo

asp无刷新读取数据!
如何上让ASP无刷新读取数据,我现在使用的代码只能读取一个值,如何可以读取多个值!

前段界面

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><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>兼容多浏览器的AJAX入门实例</title><script type="text/javascript"><!--var xmlHttp;//根据不同浏览器创建不同的XMLHttpRequest对象function createXMLHttp(){    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!");              }         }    }}//建立主过程function startXMLHttp(){      createXMLHttp(); //建立xmlHttp 对象      if( xmlHttp != undefined ){  //简单检测xmlHttp是否获取为XMLHttpRequest对象,或者使用 typeof(xmlHttp) == "object" 来检测           xmlHttp.open("get","chaxunVIP.asp?txtCard_no=0101000450",true);    //open() 方法需要三个参数。第一个参数定义发送请求所使用的方法(GET 还是 POST)。第二个参数规定服务器端脚本的 URL。第三个方法规定应当对请求进行异步地处理。           xmlHttp.send(null); //send() 方法可将请求送往服务器。           xmlHttp.onreadystatechange = doaction; //xmlHttp下的onreadystatechange 属性存有处理服务器响应的函数,注意,此处没有括号      }}function doaction(){     if(xmlHttp.readyState==4){ // xmlHttp下的readyState方法 4表示传送完毕          if(xmlHttp.status==200){ // xmlHttp的status方法读取状态(服务器HTTP状态码) 200对应OK 404对应Not Found(未找到)等//               document.getElementById("content").innerHTML=xmlHttp.responseText; //xmlHttp的responseText方法 得到读取页数据                 document.getElementById("content").value = xmlHttp.responseText;//               document.getElementById("txt1").innerHTML=xmlHttp.responseText;          }     }}--></script></head><body><input id="content" type="text" name="content" /><input id="content1" type="text" name="content1" /><input type="button" onclick="javascript:startXMLHttp()" value="查询"/></body></html>


后台程序


VBScript code
<!--#include file="../include/data_config.asp" --><%'-------------------------------------------'//禁止缓存该页 让AJAX读取该页始终为最新而非过期缓存页Response.Expires = 0 Response.Expiresabsolute = Now() - 1 Response.AddHeader "pragma","no-cache" Response.AddHeader "cache-control","private" Response.CacheControl = "no-cache"'-------------------------------------------response.Charset="GB2312" '//数据返回的编码类型 显示中文数据必须'-------------------------------------------Set rs=Server.CreateObject("ADODB.RecordSet")strSQL="select * from Card where card_no ='"&request("txtCard_no")&"'"rs.open strSQL,Conn,1,1response.Write(rs("card_no"))response.Write(rs("che_no")) rs.close conn.close'在这里还可以进行一大堆数据库操作。%>


[解决办法]
Set rs=Server.CreateObject("ADODB.RecordSet")
strSQL="select * from Card where card_no ='"&request("txtCard_no")&"'"
rs.open strSQL,Conn,1,1
'这里要加上循环的啊
while not rs.eof

response.Write(rs("card_no"))
response.Write(rs("che_no"))

rs.movenext
wend

rs.close


conn.close
'在这里还可以进行一大堆数
[解决办法]
你的代码里面没有循环..

读书人网 >ASP

热点推荐