XMLHTTP 经典 asp Post [英] XMLHTTP classic asp Post

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

问题描述

我正在使用经典 ASP Web 应用程序.这里的目标是在没有客户端等待响应的情况下进行耗时的数据处理.这导致使用 xmlhttp 对象异步发布.这是应该发布到所需 URL 的一段代码.我可以在输入 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 Post的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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