XMLHTTP对象参考之XMLHttpRequest

信息分类:XmlHttp对象参考 来源:Internet 作者:转载并修改 返回首页

XMLHttpRequest
    提供客户端同http服务器通讯的协议

例子
    下面的代码是在JScript中创建一个XMLHTTP对象并从服务器请求一个XML文档。服务器返回XML文档并显示。
    var xmlHttpReq = new ActiveXObject("MSXML2.XMLHTTP.3.0");
    xmlHttpReq.open("GET", "http://localhost/books.xml", false);
    xmlHttpReq.send();
    alert(xmlHttpReq.responseText);

    在非IE的浏览器中,需要用new XMLHttpRequest()来创建对象,如下:
    var xmlHttpReq = new XMLHttpRequest();
    xmlHttpReq.open("GET", "http://localhost/books.xml", false);
    xmlHttpReq.send();
    alert(xmlHttpReq.responseText);

    vbscript:
    Dim HttpReq As New MSXML2.XMLHTTP30
    HttpReq.open "GET", "http://localhost/books.xml", False
    HttpReq.send
    MsgBox HttpReq.responseText

备注
    客户端可以通过XmlHttp对象(MSXML2.XMLHTTP.3.0)向http服务器发送请求并使用微软XML文档对象模型Microsoft® XML Document Object Model (DOM)处理回应。

相关资源