ajax - 用于 VBA 检索大型 HTTP 请求的 MSXML2 的替代方案,并可访问 ReadyState 3?

标签 ajax vba

编辑:随着我等待答案并进行外部研究,这个问题已经改变。我已经重新表述了标题,问题实际上是我正在寻找 MSXML2 的替代方案(即使这意味着编写套接字代码)。 问题的原始正文留在这里供引用,并帮助将来进行类似搜索的人。

In VBA, using MSXML2 object, is there a way to get access to the streaming data while readyState = 3, as it comes in?

I am using the OnReadyStateChange method, but I don't seem to have access to responseText until readyState is 4. When readyState is 3, there doesn't seem to be any data.

Is there any way in VBA to have access to the HTTP streaming response while it is coming in? Another method I could use in MSXML2, or a better (free, distributable) object to use to make "AJAX" calls?

More information: If I try to read responseStream (or responseText), the error description is:

The data necessary to complete this operation is not yet available.

Second edit, more information: This link basically says that this is expected behavior in the INTERACTIVE (3) state:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms753800(v=vs.85).aspx

所以我肯定在寻找“还有其他选择吗?”回答。

最佳答案

这是我编写的一段旧代码,用于使用 WinInet API 读取 block ,它不是异步的,但它在每 512 个字节后公开一个读取缓冲区(我添加了 Debug.Print "READ "和 lngTotalBytesRead 来说明) - http://pastebin.com/6uMhkBUF

据我所知,它工作正常,但我不得不对其进行一些修复。

  • 您需要在 HTTPGetUAString 中删除对 App. 的调用(最初是 VB6),因此只需 HTTPGetUAString = "MyThing" 或类似内容。

  • If (lngContentLen = 0&) then lngContentLen = (BUFF_LEN * DUMMY_BUFF_MULTIPLIER) 是剩余的;你可以删除该行。 (随后,如果 lngContentLen 为零,则大小提前未知)

关于ajax - 用于 VBA 检索大型 HTTP 请求的 MSXML2 的替代方案,并可访问 ReadyState 3?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13744301/

相关文章:

javascript - 包含 jQuery $.post() 函数的函数的返回值

excel - 从输入框获取日期

excel - 验证单元格并获得成绩

vba - 将行复制到新工作表 VBA

Asp.net 页面管理

php - 检查用户名是否存在 - 跨浏览器问题!建议?

jquery - rails 上的 ruby : vote/unvote using ajax

javascript - INVALID_STATE_ERR : DOM Exception 11

vba - Excel VBA - 从剪贴板粘贴

mysql - PowerPoint幻灯片显示来自MySql数据库的数据?如何?