xmlhttp實(shí)現(xiàn)無刷新獲取數(shù)據(jù)的例子:
--------- test1.htm -----------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script language="vbscript">
function change(a)
dim xmlhttp
set xmlhttp = CreateObject("Microsoft.XMLHTTP")
xmlhttp.open "POST","test1.asp?a=" & a, false
xmlhttp.send
document.all.text2.value = xmlhttp.responseText
set xmlhttp = nothing
end function
</script>
</HEAD>
<BODY>
<input name="text1" onchange="vbscript:change(document.all.text1.value)">
<input name="text2">
</BODY>
</HTML>
--------- test1.asp -----------------------
<%
a = replace(trim(request("a")), "'", "")
dim conn,rs
set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.mappath("test.mdb") & ";Persist Security Info=False"
' 假設(shè)字段名為 a, b
set rs = conn.execute("select b from table1 where a='" & a & "'")
if not rs.eof then
response.write rs("b")
else
response.write ""
end if
set rs = nothing
set conn = nothing
%>
原創(chuàng)文章轉(zhuǎn)載請注明:文章轉(zhuǎn)載自 記憶盒子 [http://gazebo2go.com/blog/]
本文地址:http://gazebo2go.com/blog/archives/xml-getting-data-with-no-refresh.html