共用方式為


IHTMLXDomainRequest interface

Implements cross-domain Asynchronous JavaScript and XML (AJAX) requests between the browser and a server.

Members

The IHTMLXDomainRequest interface inherits from the IDispatch interface. IHTMLXDomainRequest also has these types of members:

  • Methods
  • Properties

Methods

The IHTMLXDomainRequest interface has these methods.

Method Description
abort

The abort method terminates a pending send.

open (XDomainRequest)

Creates a connection with a domain's server.

send (XDomainRequest)

Transmits a data string to the server for processing.

 

Properties

The IHTMLXDomainRequest interface has these properties.

Property Description

contentType

Gets the Content-Type property in the HTML request or response header.

onerror

Gets or sets the method to handle the onerror event.

onload

Gets or sets the method to handle the onload event.

onprogress

Gets or sets the method to handle the onprogress event.

ontimeout

Gets or sets the method to handle the ontimout event.

responseText

Contains the body of the response returned by the server.

timeout

Gets or sets the value of the timeout property.

 

Remarks

Cross-domain requests require mutual consent between the Web page and the server. You can initiate a cross-domain request by creating an XDomainRequest (XDR) object with the window object, and opening a connection to a URL. When sending the request, Windows Internet Explorer 8 includes an XDomainRequest: 1 HTTP request header. The connection is completed only if the server responds with an XDomainRequestAllowed: 1 response header.

To use the XDR protocol, you first create an XDomainRequest object. Then you use the IHTMLXDomainRequest::open method to establish a connection with a server. Once a connection is opened, the IHTMLXDomainRequest::send method transmits data strings to the server for processing. For example:

  
// 1. Create XDR object 
xdr = new XDomainRequest(); 

// 2. Open connection with server using POST method
xdr.open("POST", "https://www.contoso.com/xdr.txt");

// 3. Send string data to server
xdr.send("data to be processed");     
                

For more information, see XDomainRequest.

Requirements

Minimum supported client

Windows XP with SP2

Minimum supported server

Windows Server 2003

Header

Mshtml.h

IDL

Mshtml.idl

DLL

Mshtml.dll

See also

IDispatch

Introducing Cross-domain Request