Using Msxml2.serverxmlhttp in ASP to implement asynchronous request example _ application technique

Source: Internet
Author: User
Tags current time

When ASP uses Msxml2.serverxmlhttp to send requests asynchronously, it is necessary to be aware of whether the Msxml2.serverxmlhttp object's readystate is 4, and if you do not judge the properties of the object directly, such as ResponseText, the following error occurs:

Copy 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 send the request source code asynchronously:

Copy 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://root.jb51.net/a.asp?dc=1", true ' initiates an asynchronous request
Xmlserverhttp.send

While Xmlserverhttp.readystate <> 4 ' note here to determine the state of the XHR object, if not 4 then wait for 1000ms, or the bottom of the sentence will be reported above the error
Xmlserverhttp.waitforresponse 1000
Wend

Response.ContentType = "Text/html"
Response.Write "Receiver Page:" & Xmlserverhttp.responsetext & "<br/>"
%>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.