例
Set XmlHttp2 = CreateObject("Msxml2.XMLHTTP")
XmlHttp2.Open "GET", Url, True
XmlHttp2.setRequestHeader "CONTENT-TYPE", "application/json;charset=utf-8"
XmlHttp2.send PostMsg
1、使用MSXML2.XMLHTTP open中参数设置为True
2、onreadystatechange 进行设置
方式有:1)使用Timer
2)WithEvents声明的DomDocument对象load Xml
3)自定义类,新建类方法来处理事件,然后把类赋给XMLHTTP对象的OnReadyStateChange事件
3、详细内容参考MSDN
https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms757030(v=vs.85)
Use the onReadyStateChange Property (Visual Basic)
- 10/27/2016
- 4 minutes to read
This topic discusses the implementation details necessary to use
onreadystatechange
notification in Microsoft Visual Basic applications.Background Information for onReadyStateChange events
The
onreadystatechange
callback function was not implemented as a COM automation event in theIXMLHTTPRequest
andIServerXMLHTTPRequest
components. This is because these components are heavily used in scripting environments, many of which do not support COM events. Theonreadystatechange
callback function was intended to be easy to use when working with scripting clients such as VBScript and JScript.Because the
onreadystatechange
property was not implemented through COM-based automation events, Visual Basic (and C/C++) applications need to implement thi