xmlhttp实现无刷新获取数据的例子:
--------- 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"
' 假设字段名为 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
%>
原创文章转载请注明:文章转载自 记忆盒子 [http://www.webkaka.com/blog/]
本文地址:http://www.webkaka.com/blog/archives/xml-getting-data-with-no-refresh.html
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。