如何在 asp classic 中触发异步调用并忽略响应? [英] How do I fire an asynchronous call in asp classic and ignore the response?
问题描述
这里是要点:
我想在 asp 中拨打电话,但我不关心响应.我只想触发呼叫,我不希望页面等待响应.根据文档,它应该看起来像这样:
I have a call I want to make in asp, and I do not care about the response. I just want to fire the call and I do not want the page to wait for the response. According to the documentation, it should look something like this:
dim xmlhttp : set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "POST", url, true '' setting the 'asynchronous' option to 'true'
xmlhttp.setRequestHeader "Content-Type", "application/soap+xml; charset=utf-8"
xmlhttp.setRequestHeader "Content-Length", Len(XMLData)
xmlhttp.send XMLData
这在同步调用时效果很好,但是当我将异步选项切换为true"时,什么都不会触发.我可以从互联网上收集到的是用户会执行以下操作:
This works peachy when calling synchronously, but when I flip the ansynchronous option to 'true', nothing fires. What I can gather from the internet is that users do something like the following:
While xmlhttp.readyState <> 4
xmlhttp.waitForResponse 1000
Wend
如果您正在等待响应,这看起来不再像是一个异步调用,我疯了吗?
Am I crazy in that this does not really seem like an asynchrous call anymore though if you are waiting for a response?
在发送之后放置 xmlhttp.waitForResponse 1
行会导致请求触发,但同样,我不想等待.
putting the line xmlhttp.waitForResponse 1
right after the send will cause the request to fire, but again, I don't want to wait a second.
有什么想法吗?
推荐答案
今天我遇到了同样的问题.我通过使用Microsoft.XMLHTTP"对象解决了它.
Today I got the same issue. I resolved it by using "Microsoft.XMLHTTP" object.
dim xmlhttp
set xmlhttp = Server.CreateObject("Microsoft.XMLHTTP")
xmlhttp.Open "POST", url, true
xmlhttp.Send ""
现在请求被异步发送并且目标 URL 被命中.希望对您有所帮助.
And now the request is sent asynchronously and target URL was hit. Hope that helps.
这篇关于如何在 asp classic 中触发异步调用并忽略响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!