Provides client-side protocol support for communication with HTTP servers.
A client computer can use the XMLHttpRequest object (Msxml2.XMLHTTP) to send an arbitrary HTTP request, receive the response, and have the Microsoft XML DOM parse that response.
This object is integrated with the Microsoft XML Parser (MSXML) to support sending the request body directly from, and parsing the response directly into, the MSXML DOM objects. When combined with the support for XSL, the XMLHttpRequest component provides an easy way to send structured queries to HTTP servers and efficiently display the results with a variety of presentations.
The usual sequence is to call open, set any custom header information via setRequestHeader followed by send, and then to check one of the four different response properties.
The following JScript example posts a DOMDocument containing order information to an .asp page on a server and returns the result as a new XML document.
<script language="JScript"> function PostOrder(xmldoc) { var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); xmlhttp.Open("POST", "http://myserver/orders/processorder.asp", false); xmlhttp.Send(xmldoc); return xmlhttp.responseXML; } </script>
The .asp page on the server loads the posted XML document, processes the order, and builds a resulting XML document.
<%@ language=javascript %> <% Response.Expires = -1000; // Load the posted XML document. var doc = Server.CreateObject("Msxml2.DOMDocument"); doc.load(Request); var result = Server.CreateObject("Msxml2.DOMDocument"); // Now process the order and build the result document. Response.ContentType = "text/xml"; result.save(Response); %>
Properties, Methods, and Events