日期:2014-05-16  浏览次数:20809 次

Msxml2.ServerXMLHTTP异步发送请求无效
Function PostHttpPage(PostUrl,PostData) 
Dim xmlHttp 
Dim RetStr      
Set xmlHttp = CreateObject("Msxml2.ServerXMLHTTP") 
xmlHttp.setTimeouts 30000,30000,30000,60000 
'On Error Resume Next
xmlHttp.Open "POST", PostUrl, true
XmlHTTP.setRequestHeader "Content-Length", Len(PostData) 
xmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded;charset=UTF-8"
xmlHttp.Send PostData
If Err.Number <> 0 Then 
Set xmlHttp=Nothing
PostHttpPage = "$False$"
Exit Function
End If
PostHttpPage= "$False$"
Set xmlHttp = nothing
End Function



上面是我的异步发送请求的函数,服务器接收不到我的请求,请问是什么原因,总觉得这个函数有问题,我是在同步请求函数上修改了xmlHttp.Open "POST", PostUrl, false 这个函数的第三个参数改成了true,谁能提供一个Msxml2.ServerXMLHTTP发送异步请求的正确的函数给我,非常感谢!
------解决方案--------------------
本帖最后由 net_lover 于 2013-11-29 08:58:47 编辑
例子
Dim xmlServerHttp
set xmlserverhttp = server.createobject("MSXML2.ServerXMLHTTP")
xmlServerHttp.open "GET", "http://localhost/receiver.asp", true
xmlServerHttp.send

While xmlServerHttp.readyState <> 4
    xmlServerHttp.waitForResponse 1000
Wend

response.contenttype = "text/html"
response.write "Receiver Page: " & xmlServerHttp.responseText & "<br/>"