I am working with Classic ASP web application. Goal here is to do a time consuming data processing without having client to wait for a response. That resulted in using xmlhttp object async post. Here is the piece of code that should post to desired URL. I am able to hit this page directly when typing the url, and all data processing is functional, howeve开发者_开发问答r i am unable to kick start this send request in my vbscript. I opted for VBscript because i am doing validations and making sure data is in desired format prior to xmlhttp post versus calling in javascript. I am jammed here for a while now, and truly will appreciate your help.
Dim objXMLHTTP
Set objXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
objXMLHTTP.Open "POST", "myurl", true
objXMLHTTP.Send
Set objXMLHTTP = nothing
-aFellowDevInNeed
If you're doing async, you will need a delegate function to handle the state change of the request. When readyState is 4, the request was sent to the server and a full response was received. We also check to make sure that the request was HTTP 200 OK; otherwise, there may have been an error, or we received a partial response from the server:
Dim objXML
Function objXML_onreadystatechange()
If (objXML.readyState = 4) Then
If (objXML.status = 200) Then
Response.Write(objXML.responseText)
Set objXML = Nothing
End If
End If
End Function
Set objXML = Server.CreateObject("MSXML2.ServerXMLHTTP")
Call objXML.open("POST", "http://localhost/test.asp", True)
objXML.onreadystatechange = GetRef("objXML_onreadystatechange")
objXML.send()
This all being said, doing an async call in Classic ASP is not 100%. If the user aborts the request by hitting Stop, Refresh, or closes their browser, the request will be considered aborted.
http://msdn.microsoft.com/en-us/library/ms535874(v=vs.85).aspx
精彩评论