XMLHttpRequest
提供客户端同http服务器通讯的协议
Example
下面的代码是在JScript中创建一个XMLHTTP对象并从服务器请求一个XML文档。服务器返回XML文档并显示。
var xmlHttpReq = new ActiveXObject("MSXML2.XMLHTTP.3.0");
xmlHttpReq.open("GET", "http://www.ajaxstu.com/books.xml", false);
xmlHttpReq.send();
alert(xmlHttpReq.responseText);
在非IE的浏览器中,需要用new XMLHttpRequest()来创建对象,如下:
var xmlHttpReq = new XMLHttpRequest();
xmlHttpReq.open("GET", "http://www.ajaxstu.com/books.xml", false);
xmlHttpReq.send();
alert(xmlHttpReq.responseText);
vbscript:
Dim HttpReq As New MSXML2.XMLHTTP30
HttpReq.open "GET", "http://www.ajaxstu.com/books.xml", False
HttpReq.send
MsgBox HttpReq.responseText
备注
客户端可以通过XmlHttp对象(MSXML2.XMLHTTP.3.0)向http服务器发送请求并使用微软XML文档对象模型Microsoft® XML Document Object Model (DOM)处理回应。
XMLHttpRequest对象
原创文章如转载,请注明:转载自悠悠博客 [ http://www.ajaxstu.com/ ]
相关文章:
- xmlhttp:onreadystatechange属性(2006-9-16 8:13:39)
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
