开发者

"Run-time Error, data for this operation is not usable yet" message from my VB6 program

Private Sub Command1_Click()
  Dim dom As New DOMDocument
  Dim http As New XMLHTTP
  Dim strRet As String
  If Not dom.Load("c:\\CH.xml") Then MsgBox "文件不存在"
  http.Open "Post", "http://172.31.132.173/u8eai/import.asp", True '指定服务器ASP
  http.send dom.xml '把xml数据发送服务器端
  strRet = http.开发者_StackOverflow社区responseText 'strRet:返回的xml格式的回执信息
  MsgBox strRet
End Sub

The error message, in Chinese: 实时错误 完成该操作所需的数据还不可使用. translated by google(To English): Real-time error The data needed to complete the operation can not be used also


("实时错误 完成该操作所需的数据还不可使用" means "Run-time Error, data for this operation is not usable yet.")

The problem is you're issuing the HTTP request as asynchronous

http.Open "Post", "http://172.31.132.173/u8eai/import.asp", True

which means the send method will return immediately even before the server responses.

http.send dom.xml

but before the server responses you're asking the responseText value already. Of course this will cause the runtime error.

strRet = http.responseText

One workaround is to issue a synchronous request, i.e. change the 3rd parameter of http.open to False. A better method is set a handler of http's to handle the readyStateChange event (consult the doc for detail).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜