Microsoft XML 2.5 SDK


 

XMLHttpRequest Object

[This is preliminary documentation and subject to change.]

The XMLHttpRequest object provides client-side protocol support for communication with HTTP servers.

Remarks

A client computer can use the XMLHttpRequest object (Microsoft.XMLHTTP) to send an arbitrary HTTP request, receive the response, and have the Microsoft XML Document Object Model (XMLDOM) parse that response.

This object is integrated with MSXML to support sending the request body directly from, and parsing the response directly into, the MSXML Document Object Model 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 checking one of the four different response properties.

Example

The following JScript example posts an XMLDOMDocument 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("Microsoft.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("Microsoft.XMLDOM");
    doc.load(Request);
    var result = Server.CreateObject("Microsoft.XMLDOM");
    // now process the order and build the result document.
    Response.ContentType = "text/xml";
    result.save(Response);
%>

See Also

Properties, Methods, and Events | XMLDOMDocument Object