Microsoft XML 2.5 SDK


 

IXMLHttpRequest Interface

[This is preliminary documentation and subject to change.]

This interface provides client-side protocol support for communication with HTTP servers.

IXMLHttpRequest Methods

abort Cancels the current HTTP request.
getAllResponseHeaders Retrieves the values of all the HTTP headers.
getResponseHeader Retrieves the value of an HTTP header from the response body.
onreadystatechange Specifies the event handler to be invoked when the readyState property changes.
open Initializes a Microsoft.XMLHTTP request, and specifies the method, URL, and authentication information for the request.
readyState Represents the state of the request.
responseBody Represents the response entity body as an array of unsigned bytes.
responseStream Represents the response entity body as an IStream.
responseText Represents the response entity body as a string.
responseXML Represents the response entity body as parsed by the MSXML DOM parser.
send Sends an HTTP request to the server and receives a response.
setRequestHeader Specifies the name of an HTTP header.
status Represents the HTTP status code returned by a request.
statusText Represents the HTTP response line status.

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 (DOM) 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 IXMLDOMDocument ("Microsoft.XMLDOM") 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);
%>

Interface Information

Implementation Msxml.dll
Inherits from IDispatch
Header and IDL files Msxml.h, Xmldom.idl
Minimum availability Internet Explorer 5
Minimum operating systems Windows 95, Windows NT 4.0

See Also

IXMLDOMDocument