This article mainly introduces examples of using MSXML2.ServerXMLHTTP to implement asynchronous requests in asp. This article also gives the most common mistakes in writing MSXML2.ServerXMLHTTP asynchronous request code. Friends who need it can refer to it.
When asp uses MSXML2.ServerXMLHTTP to send a request asynchronously, you need to pay attention to determine whether the readyState of the MSXML2.ServerXMLHTTP object is 4. If you do not determine whether the properties of the object are directly obtained, such as responseText, the following error will occur:
Copy the code code as follows:msxml3.dll error '8000000a'
The data required to complete this operation is not yet available.
/a.asp, line 18
asp uses MSXML2.ServerXMLHTTP to asynchronously send request source code:
Copy the code code as follows:<%
if request.QueryString(dc)=1 then'xhr request outputs the current time and stops execution.
response.Write now
response.End
end if
Dim xmlServerHttp
set xmlserverhttp = server.createobject(MSXML2.ServerXMLHTTP)
xmlServerHttp.open GET, http://www.vevb.com/a.asp?dc=1, true' initiates an asynchronous request
xmlServerHttp.send
While xmlServerHttp.readyState <> 4' Note that you need to determine the status of the xhr object here. If it is not 4, wait for 1000ms, otherwise the bottom sentence will report the error posted above.
xmlServerHttp.waitForResponse 1000
Wend
response.contenttype = text/html
response.write Receiver Page: & xmlServerHttp.responseText & <br/>
%>