欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

使用xmlHttp結(jié)合ASP實(shí)現(xiàn)網(wǎng)頁(yè)的異步調(diào)用

 更新時(shí)間:2006年06月25日 00:00:00   作者:  

 

通過(guò)xmlHttp和ASP的結(jié)合,我們可以輕松完成網(wǎng)頁(yè)的異步調(diào)用。
代碼如下:
1.新建Display.asp(這是前臺(tái)顯示頁(yè)面)
注意xmlhttp.readyState的4個(gè)屬性
1:LOADING;2:LOADED;3:INTERACTIVE;4:COMPLETED

<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<script language="javascript">
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
function fnDo(ID)
{
 var xmlDom = new ActiveXObject("Msxml2.DOMDocument");
 var strURL = "GetInfo.asp?ID=" + ID;

 xmlhttp.Open("POST",strURL , true);
 xmlhttp.onreadystatechange = fnRun;

 xmlhttp.Send(xmlDom);

 divTest.innerHTML = "Loading..."
}
//--------------------------------------------------------
function fnRun()
{
 var state = xmlhttp.readyState;

 var xmlDom = new ActiveXObject("Msxml2.DOMDocument");

 if (state == 4)
 {
 xmlDom.loadXML(xmlhttp.responseXML.xml);
 //alert(xmlDom.documentElement.selectSingleNode("http://objXML").text)
 var getInfo = xmlDom.documentElement.selectSingleNode("http://objXML").text;
 divTest.innerHTML = getInfo
 }
}
</script>
<BODY>
<input type=text id=txtInput>
<input type=button value="異步調(diào)用" onclick="fnDo(document.all.txtInput.value)">
<DIV id=divTest></DIV>

<P> </P>
</BODY>
</HTML>
2.在建立GetInfo.asp(這是后臺(tái)處理頁(yè)面)
<%
Dim sID,objResult

sID = Trim(Request("ID"))
'sID = 28

Set objResult = Server.CreateObject("MSXML2.DOMDocument")
objResult.loadXML ("<objXML></objXML>")
'**************************************************************

'**************************************************************

objResult.selectSingleNode("objXML").text = "Get:" & sID

Response.ContentType = "text/xml"
objResult.save (Response)
Response.End

Set objSch = Nothing
Set objResult = Nothing
%>

3.運(yùn)行Display.asp頁(yè)面,在文本框里輸入內(nèi)容,點(diǎn)擊按鈕,可以看到Loading的提示,隨后在不刷新頁(yè)面的情況下得到了文本框里的內(nèi)容。當(dāng)然你也可以在GetInfo.asp那個(gè)頁(yè)面里根據(jù)發(fā)送的參數(shù)做一些復(fù)雜的出來(lái),隨后把結(jié)果返回出來(lái)

相關(guān)文章

最新評(píng)論