XMLHTTP经典ASP发布 [英] XMLHTTP classic asp Post

查看:93
本文介绍了XMLHTTP经典ASP发布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Classic ASP Web应用程序.目的是在不让客户端等待响应的情况下进行耗时的数据处理.这导致使用xmlhttp对象异步发布.这是应该发布到所需URL的代码段.输入网址时,我可以直接点击此页面,并且所有数据处理都可以正常运行,但是我无法在vbscript中启动该发送请求.我选择VBscript是因为我正在进行验证,并确保数据在xmlhttp发布之前与在javascript中进行调用之前处于所需的格式.我现在在这里被卡住了一段时间,非常感谢您的帮助.

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, however 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

-aFellowDevInNeed

推荐答案

如果您正在执行异步操作,则需要一个委托函数来处理请求的状态更改.当readyState为4时,请求已发送到服务器,并收到了完整的响应.我们还检查以确保请求为HTTP 200 OK.否则,可能是发生了错误,或者我们从服务器收到了部分响应:

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()

总而言之,在Classic ASP中进行异步调用不是100%.如果用户通过单击停止",刷新"或关闭其浏览器来中止请求,则该请求将被视为中止.

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

这篇关于XMLHTTP经典ASP发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆