[BACK] Return to Overview.src.html CVS log [TXT] [DIR] Up to [Public] / 2006 / webapi / XMLHttpRequest

Annotation of 2006/webapi/XMLHttpRequest/Overview.src.html, revision 1.37

1.1 avankest 1: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
 2: <html lang="en-US">
 3: <head>
 4:  <title>The XMLHttpRequest Object</title>
1.16 avankest 5:  <style type="text/css">
 6:  pre.idl { border:solid thin; background:#eee; color:#000; padding:0.5em }
 7:  pre.idl :link, pre.idl :visited { color:inherit; background:transparent }
 8:  div.example { margin-left:1em; padding-left:1em; border-left:double; color:#222; background:#fcfcfc }
 9:  p.note { margin-left:2em; font-weight:bold; font-style:italic; color:#008000 }
 10:  p.note::before { content:"Note: " }
 11:  p.issue { padding:.5em; border:solid #f00 }
 12:  p.issue::before { content:"Issue: " }
 13:  em.ct { text-transform:lowercase; font-variant:small-caps; font-style:normal }
 14:  dfn { font-weight:bold; font-style:normal }
 15:  code { color:orangered }
 16:  code :link, code :visited { color:inherit }
 17:  </style>
1.7 avankest 18:  <link rel="stylesheet" href="http://www.w3.org/StyleSheets/TR/base">
1.1 avankest 19: </head>
 20: <body>
 21:  <div class="head">
 22:  <p><a href="http://www.w3.org/"><img height="48" width="72" alt="W3C" src="http://www.w3.org/Icons/w3c_home"></a></p>
1.12 avankest 23: 
1.10 avankest 24:  <h1 class="head">The <code title="">XMLHttpRequest</code> Object</h1>
1.12 avankest 25: 
1.22 avankest 26:  <h2 class="no-num no-toc" id="pagesubtitle">Editors' draft <!--W3C Working Draft--> [DATE: 3 August 2002]</h2>
1.12 avankest 27: 
1.1 avankest 28:  <dl>
1.10 avankest 29:   <dt>This Version:</dt>
1.24 avankest 30: 
1.22 avankest 31:   <dd><a href="[VERSION]">http://www.w3.org/TR/[YEAR]/WD-XMLHttpRequest-[CDATE]/</a></dd>
1.14 avankest 32: 
1.10 avankest 33:   <dt>Latest Version:</dt>
1.24 avankest 34: 
1.1 avankest 35:   <dd><a href="http://www.w3.org/TR/XMLHttpRequest/">http://www.w3.org/TR/XMLHttpRequest/</a></dd>
1.14 avankest 36: 
1.10 avankest 37:   <dt>Previous Versions:</dt>
1.24 avankest 38: 
1.22 avankest 39:   <dd><a href="http://www.w3.org/TR/2006/WD-XMLHttpRequest-20060927/">http://www.w3.org/TR/2006/WD-XMLHttpRequest-20060927/</a></dd>
1.24 avankest 40: 
1.1 avankest 41:   <dd><a href="http://www.w3.org/TR/2006/WD-XMLHttpRequest-20060619/">http://www.w3.org/TR/2006/WD-XMLHttpRequest-20060619/</a></dd>
1.24 avankest 42: 
1.1 avankest 43:   <dd><a href="http://www.w3.org/TR/2006/WD-XMLHttpRequest-20060405/">http://www.w3.org/TR/2006/WD-XMLHttpRequest-20060405/</a></dd>
1.14 avankest 44: 
1.1 avankest 45:   <dt>Editor:</dt>
1.24 avankest 46: 
1.1 avankest 47:   <dd><a href="http://annevankesteren.nl/">Anne van Kesteren</a>
 48:   (<a href="http://www.opera.com/">Opera Software ASA</a>)
 49:   &lt;<a href="mailto:annevk@opera.com">annevk@opera.com</a>&gt;</dd>
 50:  </dl>
1.14 avankest 51: 
1.1 avankest 52:  <p class="copyright"><a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a>
 53:   ©2006
 54:   <a href="http://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup>
 55:   (<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>,
 56:   <a href="http://www.ercim.org/"><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>,
 57:   <a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C
 58:   <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
 59:   <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>
 60:   and
 61:   <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document
 62:   use</a> rules apply.
 63:  </p>
 64:  </div>
1.12 avankest 65: 
1.1 avankest 66:  <hr>
1.12 avankest 67: 
1.1 avankest 68:  <h2 class="no-num no-toc" id="specabstract">Abstract</h2>
1.10 avankest 69: 
1.22 avankest 70:  <p>The <code title="">XMLHttpRequest</code> Object specification defines an
 71:  <abbr title="Application Programming Interface">API</abbr> that provides
 72:  scripted client functionality for transferring data between a client and a
 73:  server.</p>
1.12 avankest 74: 
1.1 avankest 75:  <h2 class="no-num no-toc" id="sotd">Status of this Document</h2>
1.12 avankest 76: 
1.1 avankest 77:  <p><em>This section describes the status of this document at the time of its
1.36 avankest 78:  publication. Other documents may supersede this document. A list of current
 79:  W3C publications and the latest revision of this technical report can be
 80:  found in the <a href="http://www.w3.org/TR/">W3C technical reports index</a>
 81:  at http://www.w3.org/TR/.</em></p>
 82: 
 83:  <p>This is the [DATE: 3 August 2002] <strong>Last Call</strong> Working
 84:  Draft of The <code title="">XMLHttpRequest</code> Object specifcation. This
 85:  document is produced by the <a href="http://www.w3.org/2006/webapi/">Web API
 86:  Working Group</a>, part of the
 87:  <a href="http://www.w3.org/2006/rwc/Activity">Rich Web Clients Activity</a>
 88:  in the W3C <a href="http://www.w3.org/Interaction/">Interaction
 89:  Domain</a>.</p>
 90: 
 91:  <p>Please send comments to
 92:  <a href="mailto:public-webapi@w3.org">public-webapi@w3.org</a> with either
 93:  <samp>[XHR]</samp> or <samp title="">[XMLHttpRequest]</samp> at the start of
 94:  the subject line.
 95:  <a href="http://lists.w3.org/Archives/Public/public-webapi/">Archives</a> of
 96:  this list are available.</p>
1.12 avankest 97: 
1.1 avankest 98:  <p>Publication as a Working Draft does not imply endorsement by the W3C
1.36 avankest 99:  Membership. This is a draft document and may be updated, replaced or
 100:  obsoleted by other documents at any time. It is inappropriate to cite this
 101:  document as other than work in progress.</p>
1.12 avankest 102: 
1.1 avankest 103:  <p>This document was produced by a group operating under the
1.36 avankest 104:  <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February
 105:  2004 W3C Patent Policy</a>. This document is informative only. W3C maintains
 106:  a
 107:  <a rel="disclosure" href="http://www.w3.org/2004/01/pp-impl/38482/status">public
 108:  list of any patent disclosures</a> made in connection with the deliverables
 109:  of the group; that page also includes instructions for disclosing a patent.
 110:  An individual who has actual knowledge of a patent which the individual
 111:  believes contains
 112:  <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential
 113:  Claim(s)</a> must disclose the information in accordance with
 114:  <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section
 115:  6 of the W3C Patent Policy</a>.</p>
1.12 avankest 116: 
1.1 avankest 117:  <h2 class="no-num no-toc" id="toc">Table of Contents</h2>
1.21 avankest 118: 
1.1 avankest 119:  <!--toc-->
1.12 avankest 120: 
1.1 avankest 121:  <h2 id="introduction">Introduction</h2>
1.12 avankest 122: 
1.1 avankest 123:  <p><em>This section is non-normative.</em></p>
1.12 avankest 124: 
1.33 avankest 125:  <p>The <code>XMLHttpRequest</code> object implements an interface exposed by
 126:  a scripting engine that allows scripts to perform HTTP client functionality,
1.22 avankest 127:  such as submitting form data or loading data from a server.</p>
1.24 avankest 128: 
1.1 avankest 129:  <p>The name of the object is <code>XMLHttpRequest</code> for compatibility
1.22 avankest 130:  with the web, though each component of this name is potentially misleading.
 131:  First, the object is data transport agnostic — it supports any data format,
 132:  including XML. Second, it can be used to make requests over both HTTP and
 133:  HTTPS (some implementations support protocols in addition to HTTP and HTTPS,
 134:  but that functionality is not covered by this specification). Finally, it
 135:  supports "requests" in a broad sense of the term as it pertains to HTTP;
 136:  namely all activity involved with HTTP requests or responses for the defined
 137:  HTTP methods.</p>
1.12 avankest 138: 
1.1 avankest 139:  <h3 id="examples">Examples of Usage</h3>
1.12 avankest 140: 
1.1 avankest 141:  <p><em>This section is non-normative.</em></p>
1.12 avankest 142: 
1.37 ! avankest 143:  <p>Some [<cite><span>ECMAScript</span></cite>] examples
1.32 avankest 144:  are listed in the specification. In addition, you can find some below.</p>
1.14 avankest 145: 
 146:  <div class="example">
 147:  <p>Some simple code to do something with data from an XML document fetched
1.22 avankest 148:  over the network:</p>
1.16 avankest 149: 
1.14 avankest 150:  <pre>function test(data) {
 151: // taking care of data
 152: }
 153: 
 154: function handler() {
 155: if(this.readyState == 4 && this.status == 200) {
 156:  // so far so good
 157:  if(this.responseXML != null && this.responseXML.getElementById('test').firstChild.data)
 158:  // success!
 159:  test(this.responseXML.getElementById('test').firstChild.data);
 160:  else
 161:  test(null);
 162: } else if (this.readyState == 4 && this.status != 200) {
 163:  // fetched the wrong page or network error...
 164:  test(null);
 165: }
 166: }
1.12 avankest 167: 
1.14 avankest 168: var client = new XMLHttpRequest();
 169: client.onreadystatechange = handler;
 170: client.open("GET", "test.xml");
 171: client.send();</pre>
1.16 avankest 172: 
1.14 avankest 173:  <p>If you just want to ping the server with a message you could do something
1.22 avankest 174:  like:</p>
1.16 avankest 175: 
1.14 avankest 176:  <pre>function ping(message) {
 177: var client = new XMLHttpRequest();
 178: client.open("POST", "/ping");
 179: client.send(message);
 180: }</pre>
1.16 avankest 181: 
1.14 avankest 182:  <p>Or if you want to check the status of a document on the server:</p>
1.16 avankest 183: 
1.14 avankest 184:  <pre>function fetchStatus(address) {
 185: var client = new XMLHttpRequest();
 186: client.onreadystatechange = function() {
 187:  // in case of network errors this might not give reliable results
 188:  if(this.readyState == 4)
 189:  returnStatus(this.status);
 190: }
 191: client.open("HEAD", address);
 192: client.send();
 193: }</pre>
 194:  </div>
1.12 avankest 195: 
1.1 avankest 196:  <h3 id="conformance">Conformance</h3>
1.12 avankest 197: 
1.27 avankest 198:  <p>Everything in this specification is normative except for diagrams,
 199:  examples, notes and sections marked non-normative.</p>
1.12 avankest 200: 
1.1 avankest 201:  <p>The key words <em class="ct">must</em>, <em class="ct">must not</em>,
1.22 avankest 202:  <em class="ct">required</em>, <em class="ct">shall</em>, <em class="ct">shall
 203:  not</em>, <em class="ct">should</em>, <em class="ct">should not</em>,
 204:  <em class="ct">recommended</em>, <em class="ct">may</em> and
 205:  <em class="ct">optional</em> in this document are to be interpreted as
1.37 ! avankest 206:  described in RFC 2119 [<cite><span>RFC2119</span></cite>].</p>
1.12 avankest 207: 
1.1 avankest 208:  <p>This specification defines the following classes of products:</p>
1.12 avankest 209: 
1.1 avankest 210:  <dl>
 211:  <dt><dfn>conforming implementation</dfn></dt>
1.24 avankest 212: 
1.8 avankest 213:  <dd>A user agent that implements all interfaces described in this
1.22 avankest 214:  specification and follows all <em class="ct">must</em>-,
1.27 avankest 215:  <em class="ct">required</em>- and <em class="ct">shall</em>-level of criteria
1.22 avankest 216:  in this specification.</dd>
1.24 avankest 217: 
1.1 avankest 218:  <dt><dfn>conforming document</dfn></dt>
1.24 avankest 219: 
1.1 avankest 220:  <dd>A document that follows all <em class="ct">must</em>-,
1.27 avankest 221:  <em class="ct">required</em>- and <em class="ct">shall</em>-level of criteria
1.22 avankest 222:  in this specification that apply to document authors.</dd>
1.24 avankest 223: 
1.1 avankest 224:  <dt><dfn>conforming authoring tool</dfn></dt>
1.24 avankest 225: 
1.1 avankest 226:  <dd>One that produces conforming documents.</dd>
 227:  </dl>
1.32 avankest 228: 
1.30 avankest 229:  <h4 id="dependencies">Dependencies</h4>
1.33 avankest 230: 
1.29 avankest 231:  <p>This specification relies on several underlying specifications.</p>
 232:  <dl>
 233:  <dt>DOM</dt>
1.33 avankest 234: 
1.29 avankest 235:  <dd>
 236:   <p>Implementations <em class="ct">must</em> support some version of DOM
1.37 ! avankest 237:   Events because this specification uses some of the features defined in
 ! 238:   that specification. [<cite><span>DOM3Events</span></cite>]</p>
 ! 239:   
 ! 240:   <p>Implementations <em class="ct">must</em> support some version of DOM
 ! 241:   Core because this specification uses some of the features defined in that
 ! 242:   specification. [<cite><span>DOM3Core</span></cite>]</p>
1.29 avankest 243: 
 244:   <p>Implementations <em class="ct">must</em> support some version of the
1.37 ! avankest 245:   Window Object because some of the functionality in this specification
 ! 246:   relies on it. [<cite><span>Window</span></cite>]</p>
1.29 avankest 247:  </dd>
 248: 
 249:  <dt>HTTP</dt>
1.33 avankest 250: 
1.29 avankest 251:  <dd>
 252:   <p>Implementations <em class="ct">must</em> support the <code>http</code>
 253:   scheme defined in HTTP. Other requirements regarding HTTP are made
 254:   throughout the specification
1.37 ! avankest 255:   [<cite><span>RFC2616</span></cite>].</p>
1.29 avankest 256:  </dd>
 257:  </dl>
1.12 avankest 258: 
1.1 avankest 259:  <h3 id="extensibility">Extensibility</h3>
1.12 avankest 260: 
 261:  <p><em>This section is non-normative.</em></p>
 262: 
1.25 avankest 263:  <p>Extensions of the APIs defined by this specification are <em>strongly
1.22 avankest 264:  discouraged</em>. User agents, Working Groups and other interested parties
1.33 avankest 265:  should discuss extensions on a relevant public forum, preferably
1.22 avankest 266:  <a href="mailto:public-webapi@w3.org">public-webapi@w3.org</a>.</p>
1.12 avankest 267: 
 268:  <h2 id="xmlhttprequest">The <code title="">XMLHttpRequest</code> Object</h2>
 269: 
1.1 avankest 270:  <p>The <code>XMLHttpRequest</code> interface may be used to allow scripts to
1.22 avankest 271:  programmatically connect to their originating server via HTTP.</p>
1.12 avankest 272: 
1.1 avankest 273:  <p>Objects implementing the <code>XMLHttpRequest</code> interface
1.22 avankest 274:  <em class="ct">must</em> also implement the <code>EventTarget</code>
1.37 ! avankest 275:  interface [<cite><span>DOM3Events</span></cite>].</p>
1.12 avankest 276: 
1.37 ! avankest 277:  <p>In [<cite><span>ECMAScript</span></cite>], an instance
1.34 avankest 278:  of <code>XMLHttpRequest</code> can be created using the
1.22 avankest 279:  <code title="">XMLHttpRequest()</code> constructor:</p>
1.12 avankest 280: 
1.1 avankest 281:  <div class="example">
 282:  <pre>var client = new XMLHttpRequest();</pre>
 283:  </div>
1.12 avankest 284: 
1.37 ! avankest 285:  <p>When the constructor is invoked a pointer to the
 ! 286:  <code title="">Window</code> object which initially had
 ! 287:  <code title="">XMLHttpRequest</code> as an attribute of which the
 ! 288:  constructor was invoked <em class="ct">must</em> be stored on the newly
 ! 289:  created object, called the
1.25 avankest 290:  <dfn title="Window pointer" id="window-pointer"><code>Window</code>
 291:  pointer</dfn>. This <span title="Window pointer">pointer</span>
 292:  <em class="ct">must</em> persist even if the browsing context in which the
1.37 ! avankest 293:  <code title="">Window</code> is located is destroyed (by removing it from a
 ! 294:  parent browsing context, for instance).</p>
1.25 avankest 295: 
1.37 ! avankest 296:  <p>The term browsing context is defined by the <cite>Window Object
 ! 297:  1.0</cite> specification. [<cite><span>Window</span></cite>]</p>
1.27 avankest 298: 
 299:  <!-- XXX if the document object changes in the browsing context you get an
1.33 avankest 300:  exception in some implementations. -->
1.27 avankest 301: 
1.31 avankest 302:  <h3 id="xmlhttprequest-members">Members of the
 303:  <code title="">XMLHttpRequest</code> Object</h3>
1.12 avankest 304: 
1.1 avankest 305:  <pre class="idl">interface <dfn>XMLHttpRequest</dfn> {
1.7 avankest 306:      attribute EventListener  <span>onreadystatechange</span>;
1.1 avankest 307:  readonly attribute unsigned short <span>readyState</span>;
1.12 avankest 308:  void        <span>open</span>(in DOMString <var>method</var>, in DOMString <var>url</var>);
 309:  void        <span>open</span>(in DOMString <var>method</var>, in DOMString <var>url</var>, in boolean <var>async</var>);
 310:  void        <span>open</span>(in DOMString <var>method</var>, in DOMString <var>url</var>, in boolean <var>async</var>, in DOMString <var>user</var>);
 311:  void        <span>open</span>(in DOMString <var>method</var>, in DOMString <var>url</var>, in boolean <var>async</var>, in DOMString <var>user</var>, in DOMString <var>password</var>);
1.3 avankest 312:  void        <span>setRequestHeader</span>(in DOMString <var>header</var>, in DOMString <var>value</var>);
1.1 avankest 313:  void        <span>send</span>();
1.3 avankest 314:  void        <span>send</span>(in DOMString <var>data</var>);
 315:  void        <span>send</span>(in Document <var>data</var>);
1.1 avankest 316:  void        <span>abort</span>();
 317:  DOMString     <span>getAllResponseHeaders</span>();
1.3 avankest 318:  DOMString     <span>getResponseHeader</span>(in DOMString <var>header</var>);
1.7 avankest 319:  readonly attribute DOMString    <span>responseText</span>;
 320:  readonly attribute Document    <span>responseXML</span>;
 321:  readonly attribute unsigned short <span>status</span>;
 322:  readonly attribute DOMString    <span>statusText</span>;
1.1 avankest 323: };</pre>
1.8 avankest 324: 
1.5 avankest 325:  <dl>
1.12 avankest 326: 
1.22 avankest 327:  <dt><dfn id="dfn-onreadystatechange"><code>onreadystatechange</code></dfn> of
 328:  type <code>EventListener</code></dt>
1.12 avankest 329: 
1.1 avankest 330:  <dd>
 331:   <p>An attribute that takes an <code>EventListener</code> as value that
1.22 avankest 332:   <em class="ct">must</em> be invoked when <code>readystatechange</code> is
 333:   dispatched on the object implementing the <code>XMLHttpRequest</code>
 334:   interface. Its initial value <em class="ct">must</em> be
 335:   <code>null</code>.</p>
1.1 avankest 336:  </dd>
1.12 avankest 337: 
1.1 avankest 338:  <dt><dfn id="dfn-readystate"><code>readyState</code></dfn> of type
1.22 avankest 339:  <code>unsigned short</code>, readonly</dt>
1.12 avankest 340: 
1.1 avankest 341:  <dd>
 342:   <p>The state of the object. The attribute <em class="ct">must</em> be one of
1.22 avankest 343:   the following values:</p>
1.12 avankest 344: 
1.1 avankest 345:   <dl>
1.25 avankest 346:   <dt><dfn title="uninitialized state">0 Uninitialized</dfn></dt>
1.24 avankest 347: 
1.1 avankest 348:   <dd>The initial value.</dd>
1.24 avankest 349: 
1.25 avankest 350:   <dt><dfn title="open state">1 Open</dfn></dt>
1.24 avankest 351: 
1.1 avankest 352:   <dd>The <code>open()</code> method has been successfully called.</dd>
1.24 avankest 353: 
1.25 avankest 354:   <dt><dfn title="sent state">2 Sent</dfn></dt>
1.24 avankest 355: 
1.15 avankest 356:   <dd>The user agent successfully acknowledged the request.</dd>
1.24 avankest 357: 
1.25 avankest 358:   <dt><dfn title="receiving state">3 Receiving</dfn></dt>
1.24 avankest 359: 
1.1 avankest 360:   <dd>Immediately before receiving the message body (if any). All HTTP
1.22 avankest 361:   headers have been received.</dd>
1.24 avankest 362: 
1.25 avankest 363:   <dt><dfn title="loaded state">4 Loaded</dfn></dt>
1.24 avankest 364: 
1.1 avankest 365:   <dd>The data transfer has been completed.</dd>
 366:   </dl>
1.21 avankest 367: 
 368:   <p class="note">When <code>readyState</code> changes value a
1.22 avankest 369:   <code>readystatechange</code> event is to be dispatched on the
 370:   <code>XMLHttpRequest</code> object.</p>
1.1 avankest 371:  </dd>
1.12 avankest 372: 
1.14 avankest 373:  <dt><dfn id="dfn-open" title="open"><code>open(<var>method</var>,
1.22 avankest 374:  <var>url</var>, <var>async</var>, <var>user</var>,
 375:  <var>password</var>)</code></dfn>, method</dt>
1.12 avankest 376: 
1.1 avankest 377:  <dd>
1.26 avankest 378:   <p>Invoking this method <em class="ct">must</em> initialize the object by
 379:   remembering the <var>method</var>, <var>url</var>, <var>async</var>
 380:   (defaulting to <code>true</code> if omitted), <var>user</var> (defaulting to
 381:   <code>null</code> if omitted), and <var>password</var> (defaulting to
 382:   <code>null</code> if omitted) arguments, setting the state to
 383:   <span title="open state">open</span>, resetting the
1.22 avankest 384:   <code>responseText</code>, <code>responseXML</code>, <code>status</code>,
 385:   and <code>statusText</code> attributes to their initial values, and
 386:   resetting the list of request headers.</p>
1.12 avankest 387: 
1.26 avankest 388:   <p>In addition, when the state is not
1.27 avankest 389:   <span title="uninitialized state">uninitialized</span>, all members of the
 390:   object with the exception of <code>onreadystate</code>
 391:   <em class="ct">must</em> be set to their initial values and user agents
 392:   <em class="ct">must</em> behave as if <code>abort()</code> was invoked.</p>
1.24 avankest 393: 
1.13 avankest 394:   <p>If the <var>method</var> argument doesn't match the <dfn>method
1.37 ! avankest 395:   production</dfn> defined in section 5.1.1 of RFC 2616 a
 ! 396:   <code>SYNTAX_ERR</code>
1.22 avankest 397:   <em class="ct">must</em> be raised by the user agent. If the user agent
 398:   doesn't support the given method for security reasons a
1.37 ! avankest 399:   <code>SECURITY_ERR</code> <em class="ct">should</em> be raised.
 ! 400:   [<cite><span>RFC2616</span></cite>]</p>
1.14 avankest 401: 
1.13 avankest 402:   <p>User agents <em class="ct">must</em> at least support the following list
1.37 ! avankest 403:   of methods (see [<cite><span>RFC2616</span></cite>]):</p>
1.14 avankest 404: 
1.13 avankest 405:   <ul>
 406:   <li><code>GET</code></li>
 407:   <li><code>POST</code></li>
 408:   <li><code>HEAD</code></li>
 409:   <li><code>PUT</code></li>
 410:   <li><code>DELETE</code></li>
 411:   </ul>
1.16 avankest 412: 
1.13 avankest 413:   <p>User agents <em class="ct">should</em> support any <var>method</var>
1.22 avankest 414:   argument that matches the <span>method production</span>.</p>
1.14 avankest 415: 
1.13 avankest 416:   <p>When <var>method</var> case-insensitively matches <code>GET</code>,
1.22 avankest 417:   <code>POST</code>, <code>HEAD</code>, <code>PUT</code> or
1.25 avankest 418:   <code>DELETE</code> user agents <em class="ct">must</em> use the
1.22 avankest 419:   uppercase equivalent instead.</p>
1.12 avankest 420: 
1.33 avankest 421:   <p>When <var>url</var> is a relative reference, it
 422:   <em class="ct">must</em> be resolved using the current value of the
 423:   <code>baseURI</code> attribute of the <code>Document</code> object
 424:   currently associated with the <span><code>Window</code> pointer</span> and
 425:   the fragment identifier component, if any, <em class="ct">must</em> be
 426:   dropped. If it can't be resolved user agents <em class="ct">must</em>
 427:   throw a <code>SYNTAX_ERR</code>. When a non same-origin <var>url</var>
 428:   argument is given user agents <em class="ct">should</em> throw a
1.25 avankest 429:   <code>SECURITY_ERR</code> exception.</p>
1.14 avankest 430: 
1.19 avankest 431:   <p class="note">A future version or extension of this specification will
1.33 avankest 432:   most likely define a way of doing cross-site requests.</p>
1.21 avankest 433: 
1.37 ! avankest 434:   <p>User agents <em class="ct">should not</em> support the
 ! 435:   <code>"user:password"</code> format in the <code>userinfo</code>
 ! 436:   production defined in section 3.2.1 of RFC 3986 and
1.33 avankest 437:   <em class="ct">must</em> throw a <code>SYNTAX_ERR</code> when doing so
 438:   (not supporting it). When they do support it, or in case of people using
 439:   the format "user", user agents <em class="ct">must</em> use them if the
1.22 avankest 440:   <var>user</var> and <var>password</var> arguments are omitted. If the
 441:   arguments are not omitted, they take precedence, even if they are
1.37 ! avankest 442:   <code>null</code>. [<cite><span>RFC3986</span></cite>]</p>
1.17 avankest 443: 
 444:   <p>If the <var>user</var> argument doesn't match the
1.37 ! avankest 445:   <code>username-value</code> production defined in section 3.2.2 of RFC
 ! 446:   2617 user agents <em class="ct">must</em> throw a <code>SYNTAX_ERR</code>
 ! 447:   exception. [<cite><span>RFC2617</span></cite>]</p>
1.22 avankest 448: 
1.27 avankest 449:   <p>It is undefined in this specification what production <var>password</var>
 450:   has to match. User agents <em class="ct">may</em> throw a
 451:   <code>SYNTAX_ERR</code> for a production they don't accept.</p>
 452: 
1.37 ! avankest 453:   <p class="note">[<cite><span>RFC2617</span></cite>] doesn't
1.27 avankest 454:   clearly define what the passwd production can or can't contain.</p>
 455: 
1.34 avankest 456:   <p>When <code>null</code> is passed for either <var>user</var> or
 457:   <var>password</var> user agents <em class="ct">must</em> act as if the
 458:   relevant data (the user name or password) is not provided.</p>
1.37 ! avankest 459: 
1.34 avankest 460:   <p class="note">The empty string value is not to be treated as the
 461:   <code>null</code> value. If it's disallowed by the syntax for either
 462:   <var>user</var> or <var>password</var> a <code>SYNTAX_ERR</code> has to be
 463:   thrown as indicated above.</p>
1.1 avankest 464:  </dd>
1.12 avankest 465: 
1.14 avankest 466:  <dt><dfn id="dfn-setrequestheader" title="setrequestheader"><code>setRequestHeader(<var>header</var>,
1.22 avankest 467:  <var>value</var>)</code></dfn>, method</dt>
1.12 avankest 468: 
1.5 avankest 469:  <dd>
 470:   <p>The nominated request header (<var>header</var>) field value
1.22 avankest 471:   <em class="ct">must</em> be set to <var>value</var>, with the following
 472:   exceptions:</p>
1.14 avankest 473: 
1.5 avankest 474:   <ul>
1.25 avankest 475:   <li>If the state is not <span title="open state">open</span> or the
 476:   <span><code>send()</code> flag</span> is set an
1.22 avankest 477:   <code>INVALID_STATE_ERR</code> exception <em class="ct">must</em> be
 478:   raised;</li>
1.14 avankest 479: 
1.13 avankest 480:   <li>If the <var>header</var> argument doesn't match the
1.22 avankest 481:   <dfn><code>field-name</code> production</dfn> as defined by section 4.2
1.37 ! avankest 482:   of [<cite><span>RFC2616</span></cite>] a
1.36 avankest 483:   <code>SYNTAX_ERR</code> <em class="ct">must</em> be raised;</li>
1.14 avankest 484: 
1.13 avankest 485:   <li>If the <var>value</var> argument doesn't match the
1.22 avankest 486:   <dfn><code>field-value</code> production</dfn> as defined by section 4.2
1.37 ! avankest 487:   of [<cite><span>RFC2616</span></cite>] a
1.36 avankest 488:   <code>SYNTAX_ERR</code> <em class="ct">must</em> be raised;</li>
1.14 avankest 489: 
1.32 avankest 490:   <li>
1.35 avankest 491:    <p>For security reasons the invocation <em class="ct">should</em> be
 492:    ignored if the <var>header</var> argument matches one of the following
 493:    headers case-insensitively:</p>
1.32 avankest 494:    <ul>
 495:    <li><code>Accept-Charset</code></li>
 496:    <li><code>Accept-Encoding</code></li>
 497:    <li><code>Content-Length</code></li>
 498:    <li><code>Expect</code></li>
 499:    <li><code>Date</code></li>
 500:    <li><code>Host</code></li>
 501:    <li><code>Keep-Alive</code></li>
 502:    <li><code>Referer</code></li>
 503:    <li><code>TE</code></li>
 504:    <li><code>Trailer</code></li>
 505:    <li><code>Transfer-Encoding</code></li>
 506:    <li><code>Upgrade</code></li>
 507:    </ul>
 508:    <!-- XXX or should this throw an exception? -->
 509:   </li>
1.5 avankest 510:   </ul>
 511: 
1.32 avankest 512:   <!-- Add "Expect" back in below if we remove it above. -->
1.5 avankest 513:   <p>Implementations <em class="ct">must</em> replace any existing value if
1.32 avankest 514:   the nominated request header field value is one of:</p>
 515: 
 516:   <ul>
 517:   <li><code>Authorization</code></li>
 518:   <li><code>Content-Base</code></li>
 519:   <li><code>Content-Location</code></li>
 520:   <li><code>Content-MD5</code></li>
 521:   <li><code>Content-Range</code></li>
 522:   <li><code>Content-Type</code></li>
 523:   <li><code>Content-Version</code></li>
 524:   <li><code>Delta-Base</code></li>
 525:   <li><code>Depth</code></li>
 526:   <li><code>Destination</code></li>
 527:   <li><code>ETag</code></li>
 528:   <li><code>From</code></li>
 529:   <li><code>If-Modified-Since</code></li>
 530:   <li><code>If-Range</code></li>
 531:   <li><code>If-Unmodified-Since</code></li>
 532:   <li><code>Max-Forwards</code></li>
 533:   <li><code>MIME-Version</code></li>
 534:   <li><code>Overwrite</code></li>
 535:   <li><code>Proxy-Authorization</code></li>
 536:   <li><code>SOAPAction</code></li>
 537:   <li><code>Timeout</code></li>
 538:   </ul>
1.14 avankest 539: 
1.36 avankest 540:   <p>Otherwise, if the nominated request header field already has a value,
 541:   the new value <em class="ct">must</em> be combined with the existing value
1.37 ! avankest 542:   (section 4.2, [<cite><span>RFC2616</span></cite>]). See also the
1.36 avankest 543:   <code>send()</code> method regarding user agent header handling for
 544:   caching, authentication, proxies, and cookies.</p>
1.14 avankest 545: 
 546:   <div class="example">
 547:   <pre>// The following script:
 548: var client = new XMLHttpRequest();
 549: client.open('GET', 'demo.cgi');
 550: client.setRequestHeader('X-Test', 'one');
 551: client.setRequestHeader('X-Test', 'two');
 552: client.send();
 553: 
 554: // ...would result in the following header being sent:
 555: ...
 556: X-Test: one, two
 557: ...</pre>
 558:   </div>
 559: 
1.13 avankest 560:   <p>The list of request headers <em class="ct">must</em> be reset when the
1.22 avankest 561:   <code>open()</code> method is invoked.</p>
1.5 avankest 562:  </dd>
1.12 avankest 563: 
1.14 avankest 564:  <dt><dfn id="dfn-send" title="send"><code>send(<var>data</var>)</code></dfn>,
1.22 avankest 565:  method</dt>
1.12 avankest 566: 
1.17 avankest 567:  <dd>
1.25 avankest 568:   <p>If the state is not <span title="open state">open</span> or the
 569:   <span><code>send()</code> flag</code> is set an
 570:   <code>INVALID_STATE_ERR</code> exception <em class="ct">must</em> be raised.
 571:   Otherwise user agents <em class="ct">must</em> make a request to
1.22 avankest 572:   <var>url</var> using method <var>method</var> and set the
 573:   <dfn><code>send()</code> flag</dfn>. If the <var>async</var> flag is set to
 574:   <code>false</code>, then the method <em class="ct">must not</em> return
 575:   until the request has completed. Otherwise, it <em class="ct">must</em>
 576:   return immediately. (See: <code>open()</code>.)</p>
1.21 avankest 577: 
1.25 avankest 578:   <p class="note">Even when <var>async</var> is set to <code>false</code> the
 579:   <code>readystatechange</code> event will still be dispatched.</p>
1.27 avankest 580: 
1.20 avankest 581:   <p class="note">The <span><code>send()</code> flag</span> is only relevant
1.25 avankest 582:   when the state is <span title="open state">open</span>.</p>
1.12 avankest 583: 
 584:   <p>If <var>data</var> is passed to the <code>send()</code> method it
1.27 avankest 585:   <em class="ct">must</em> be used for the <dfn id="dfn-entity-body">entity
 586:   body</dfn> as defined by section 7.2.1 of
1.37 ! avankest 587:   [<cite><span>RFC2616</span></cite>]). The following rules
1.27 avankest 588:   apply:</p>
 589: 
 590:   <dl>
 591:   <dt><var>data</var> is a <code>DOMString</code></dt>
1.12 avankest 592: 
1.27 avankest 593:   <dd><var>data</var> <em class="ct">must</em> be encoded as UTF-8 for
 594:   transmission.</dd>
 595: 
 596:   <dt><var>data</var> is a <code>Document</code>
1.24 avankest 597: 
1.27 avankest 598:   <dd><var>data</var> <em class="ct">must</em> be serialized into a namespace
 599:   well-formed XML document and encoded using the encoding given by
 600:   <code><var>data</var>.xmlEncoding</code> (the XML declaration), if
 601:   specified, or UTF-8 otherwise. The serialization <em class="ct">must</em>
 602:   include an XML declaration when the final encoding is not UTF-8 or
 603:   UTF-16.</dd>
 604: 
 605:   <dt><var>data</var> is not a <code>DOMString</code> or
 606:   <code>Document</code></dt>
 607: 
 608:   <dd>The stringification mechanisms of the host language
 609:   <em class="ct">must</em> be used on <var>data</var> and the result
 610:   <em class="ct">must</em> be treated as if <var>data</var> is a
 611:   <code>DOMString</code>.</dd>
 612:   </dl>
1.12 avankest 613: 
1.16 avankest 614:   <p>Invoking <code>send()</code> without the <var>data</var> argument
1.22 avankest 615:   <em class="ct">must</em> give the same result as if it was invoked with
 616:   <code>null</code> as argument.</p>
1.12 avankest 617: 
 618:   <p>Authors <em class="ct">should</em> specify the <code>Content-Type</code>
1.22 avankest 619:   header via <code>setRequestHeader</code> before invoking
 620:   <code>send()</code> with an argument. If the argument to
 621:   <code>send()</code> is a <code>Document</code> and no
 622:   <code>Content-Type</code> header has been set user agents
 623:   <em class="ct">must</em> set it to <code>application/xml</code> for XML
 624:   documents and to the most appropriate media type for other documents (using
 625:   intrinsic knowledge about the document).</p>
1.12 avankest 626: 
1.14 avankest 627:   <p>If the response is an HTTP redirect (status code <code>301</code>,
1.22 avankest 628:   <code>302</code>, <code>303</code> or <code>307</code>), then it
 629:   <em class="ct">must</em> be transparently followed (unless it violates
 630:   security, infinite loop precautions or the scheme isn't supported). Note
1.37 ! avankest 631:   that HTTP ([<cite><span>RFC2616</span></cite>]) places
1.22 avankest 632:   requirements on user agents regarding the preservation of the request
 633:   method during redirects, and also requires users to be notified of certain
 634:   kinds of automatic redirections.</p>
1.12 avankest 635: 
1.25 avankest 636:   <p>Once the request has been successfully acknowledged the state
 637:   <em class="ct">must</em> be set to <span title="sent state">sent</span>.
 638:   Immediately before receiving the message body (if any), the state
 639:   <em class="ct">must</em> be set to to
 640:   <span title="receiving state">receiving</span>. When the request has
 641:   completed loading, the state <em class="ct">must</em> be set to
 642:   <span title="loaded state">loaded</span>.</p>
1.27 avankest 643: 
1.25 avankest 644:   <p class="note">This means that in case of a <code>HEAD</code> request the
 645:   state is set to <span title="loaded state">loaded</span> immediately after
 646:   having being set to <span title="receiving state">receiving</span>.</p>
 647: 
 648:   <p>If something goes wrong (infinite loop, network errors) the state
 649:   <em class="ct">must</em> be set to <span title="loaded state">loaded</span>
1.27 avankest 650:   and all members (excluding <code>readyState</code>) of the object
1.31 avankest 651:   <em class="ct">must</em> be set to their initial value. Also, if
1.33 avankest 652:   <code>async</code> is set to <code>false</code>, a
 653:   <code>NETWORK_ERR</code> exception <em class="ct">must</em> be raised. In
 654:   addition, all registered event listeners <em class="ct">must</em> be
 655:   removed.</p>
1.16 avankest 656: 
1.15 avankest 657:   <p class="note">In future versions of this specification user agents will be
1.22 avankest 658:   required to dispatch an <code>error</code> event if the above occurs.</p>
1.14 avankest 659: 
1.8 avankest 660:   <p>If the user agent allows the specification of a proxy it
1.22 avankest 661:   <em class="ct">should</em> modify the request appropriately;
 662:   <abbr title="in other words">i.e.</abbr>, connect to the proxy host instead
 663:   of the origin server, modify the <code>Request-Line</code> and send
 664:   <code>Proxy-Authorization</code> headers as specified.</p>
1.12 avankest 665: 
1.14 avankest 666:   <p>If the user agent supports <cite>HTTP Authentication</cite>
1.37 ! avankest 667:   ([<cite><span>RFC2617</span></cite>]) it
1.22 avankest 668:   <em class="ct">should</em> consider requests originating from this object
 669:   to be part of the protection space that includes the accessed URIs and send
 670:   <code>Authorization</code> headers and handle <code>401 Unauthorised</code>
 671:   requests appropriately. if authentication fails, user agents
 672:   <em class="ct">should</em> prompt the users for credentials.</p>
1.12 avankest 673: 
1.14 avankest 674:   <p>If the user agent supports <cite>HTTP State Mangement</cite>
1.37 ! avankest 675:   ([<cite><span>RFC2109</span></cite>],
 ! 676:   [<cite><span>RFC2965</span></cite>]) it
1.22 avankest 677:   <em class="ct">should</em> persist, discard and send cookies (as received in
 678:   the <code>Set-Cookie</code> and <code>Set-Cookie2</code> response headers,
 679:   and sent in the <code>Cookie</code> header) as applicable.</p>
1.12 avankest 680: 
1.8 avankest 681:   <p>If the user agent implements a HTTP cache
1.37 ! avankest 682:   ([<cite><span>RFC2616</span></cite>]) it
1.22 avankest 683:   <em class="ct">should</em> respect <code>Cache-Control</code> request
 684:   headers set by the author (<abbr title="for example">e.g.</abbr>,
 685:   <code>Cache-Control: no-cache</code> bypasses the cache). It
 686:   <em class="ct">must not</em> send <code>Cache-Control</code> or
 687:   <code>Pragma</code> request headers automatically unless the user explicitly
 688:   requests such behaviour (e.g., by (force-)reloading the page). <code>304 Not
 689:   Modified</code> responses that are a result of a user agent generated
 690:   conditional request <em class="ct">must</em> be presented as <code>200
 691:   OK</code> responses with the appropriate content. Such user agents
 692:   <em class="ct">must</em> allow authors to override automatic cache
 693:   validation by setting request headers (e.g., <code>If-None-Match</code>,
 694:   <code>If-Modified-Since</code>), in which case <code>304 Not Modified</code>
 695:   responses <em class="ct">must</em> be passed through.</p>
1.12 avankest 696: 
1.8 avankest 697:   <p>If the user agent implements server-driven content-negotiation
1.37 ! avankest 698:   ([<cite><span>RFC2616</span></cite>]) it
1.22 avankest 699:   <em class="ct">should</em> set <code>Accept-Language</code>,
 700:   <code>Accept-Encoding</code> and <code>Accept-Charset</code> headers as
 701:   appropriate; it <em class="ct">must not</em> automatically set the
 702:   <code>Accept</code> header. Responses to such requests
 703:   <em class="ct">must</em> have content-codings automatically removed.</p>
1.14 avankest 704: 
 705:   <p>If the user agent supports Expect/Continue for request bodies
1.37 ! avankest 706:   ([<cite><span>RFC2616</span></cite>]) it
1.22 avankest 707:   <em class="ct">should</em> insert <code>Expect</code> headers and handle
 708:   <code>100 Continue</code> responses appropriately.</p>
1.8 avankest 709:  </dd>
1.12 avankest 710: 
1.14 avankest 711:  <dt><dfn id="dfn-abort"><code>abort()</code></dfn>, method</dt>
1.12 avankest 712: 
1.5 avankest 713:  <dd>
 714:   <p>When invoked, this method <em class="ct">must</em> cancel any network
1.22 avankest 715:   activity for which the object is responsible and set all the members of the
1.27 avankest 716:   object to their initial values as well as removing all event listeners.</p>
1.24 avankest 717: 
 718:   <p class="note">This means that the object <em>can</em> be used for another
 719:   request in which case this method will work again to cancel it.</p>
1.5 avankest 720:  </dd>
1.12 avankest 721: 
1.14 avankest 722:  <dt><dfn id="dfn-getallresponseheaders"><code>getAllResponseHeaders()</code></dfn>,
1.22 avankest 723:  method</dt>
1.12 avankest 724: 
1.5 avankest 725:  <dd>
1.25 avankest 726:   <p>If the state is not <span title="receiving state">receiving</span> or
 727:   <span title="loaded state">loaded</span>, user agents
 728:   <em class="ct">must</em> raise an <code>INVALID_STATE_ERR</code> exception.
 729:   Otherwise, it <em class="ct">must</em> return all the HTTP headers, as a
 730:   single string, with each header line separated by a CR (U+000D) LF (U+000A)
 731:   pair. The status line <em class="ct">must not</em> be included.</p>
1.24 avankest 732: 
1.5 avankest 733:   <div class="example">
 734:   <pre>// The following script:
 735: var client = new XMLHttpRequest();
1.14 avankest 736: client.open("GET", "test.txt", true);
1.5 avankest 737: client.send();
1.12 avankest 738: client.onreadystatechange = function() {
1.13 avankest 739: if(this.readyState == 3) {
1.12 avankest 740:  print(this.getAllResponseHeaders());
 741: }
 742: }
1.5 avankest 743: 
 744: // ...should output something similar to the following text:
 745: Date: 2004年10月24日 04:58:38 GMT
 746: Server: Apache/1.3.31 (Unix)
 747: Keep-Alive: timeout=15, max=99
 748: Connection: Keep-Alive
 749: Transfer-Encoding: chunked
 750: Content-Type: text/plain; charset=utf-8</pre>
 751:   </div>
 752:  </dd>
1.12 avankest 753: 
1.18 avankest 754:  <dt><dfn id="dfn-getresponseheader" title="getresponseheader"><code>getResponseHeader(<var>header</var>)</code></dfn>,
1.22 avankest 755:  method</dt>
1.12 avankest 756: 
1.1 avankest 757:  <dd>
1.13 avankest 758:   <p>If the <var>header</var> argument doesn't match the
1.22 avankest 759:   <span><code>field-name</code> production</span> a <code>SYNTAX_ERR</code>
 760:   <em class="ct">must</em> be raised. Otherwise this method works as described
 761:   below.</p>
1.14 avankest 762: 
1.25 avankest 763:   <p>If the state is not <span title="receiving state">receiving</span> or
 764:   <span title="loaded state">loaded</span>, the user agent
 765:   <em class="ct">must</em> raise an <code>INVALID_STATE_ERR</code> exception.
 766:   Otherwise, it <em class="ct">must</em> represent the value of the given HTTP
 767:   header (<var>header</var>) in the data received so far for the last request
 768:   sent, as a single string. If more than one header of the given name was
 769:   received, then the values <em class="ct">must</em> be concatenated,
 770:   separated from each other by an U+002C COMMA followed by an U+0020 SPACE. If
 771:   no headers of that name were received, then it <em class="ct">must</em>
 772:   return <code>null</code>. Header names <em class="ct">must</em> be compared
1.22 avankest 773:   case-insensitively to the method its argument (<var>header</var>).</p>
1.12 avankest 774: 
1.1 avankest 775:   <div class="example">
 776:   <pre>// The following script:
 777: var client = new XMLHttpRequest();
1.14 avankest 778: client.open("GET", "test.txt", true);
1.5 avankest 779: client.send();
1.12 avankest 780: client.onreadystatechange = function() {
1.13 avankest 781: if(this.readyState == 3) {
1.14 avankest 782:  print(client.getResponseHeader("Content-Type"));
1.12 avankest 783: }
 784: }
1.1 avankest 785: 
1.5 avankest 786: // ...should output something similar to the following text:
 787: Content-Type: text/plain; charset=utf-8</pre>
1.1 avankest 788:   </div>
1.5 avankest 789:  </dd>
1.12 avankest 790: 
1.5 avankest 791:  <dt><dfn id="dfn-responsetext"><code>responseText</code></dfn> of type
1.22 avankest 792:  <code>DOMString</code>, readonly</dt>
1.12 avankest 793: 
1.5 avankest 794:  <dd>
1.25 avankest 795:   <p>If the state is not <span title="receiving state">receiving</span> or
 796:   <span title="loaded state">loaded</span>, the user agent
 797:   <em class="ct">must</em> raise an <code>INVALID_STATE_ERR</code> exception.
 798:   Otherwise, it <em class="ct">must</em> be the fragment of the <span>entity
 799:   body</span> received so far (when the state is
 800:   <span title="receiving state">receiving</span>) or the complete <span>entity
 801:   body</span> (when the state is <span title="loaded state">loaded</span>),
 802:   interpreted as a stream of characters.</p>
1.12 avankest 803: 
 804:   <p>If the response includes a <code>Content-Type</code> understood by the
1.22 avankest 805:   user agent the characters are encoded following the relevant media type
 806:   specification, with the exception that the rule in the final paragraph of
1.37 ! avankest 807:   section 3.7.1 of [<cite><span>RFC2616</span></cite>], and the
 ! 808:   rules in section 4.1.2 of [<cite><span>RFC2046</span></cite>]
1.22 avankest 809:   <em class="ct">must</em> be treated as if they specified the default
 810:   character encoding as being UTF-8. Invalid bytes <em class="ct">must</em> be
 811:   converted to U+FFFD REPLACEMENT CHARACTER. If the user agent can't derive a
 812:   character stream in accord with the media type specification,
 813:   <code>reponseText</code> <em class="ct">must</em> be <code>null</code>.</p>
1.12 avankest 814: 
 815:   <p>Its initial value <em class="ct">must</em> be the <code>null</code>.</p>
1.21 avankest 816: 
1.24 avankest 817:   <p class="note">For <code>HEAD</code> requests this attribute will always
 818:   be <code>null</code> (it remains unchanged). Similar to the
1.22 avankest 819:   <code>responseXML</code> attribute.</p>
1.5 avankest 820:  </dd>
1.12 avankest 821: 
1.5 avankest 822:  <dt><dfn id="dfn-responsexml"><code>responseXML</code></dfn> of type
1.22 avankest 823:  <code>Document</code>, readonly</dt>
1.12 avankest 824: 
1.8 avankest 825:  <dd>
1.25 avankest 826:   <p>If the state is not <span title="loaded state">loaded</span>, user agents
 827:   <em class="ct">must</em> raise an <code>INVALID_STATE_ERR</code> exception.
 828:   Otherwise, if the <code>Content-Type</code> header contains a media type
 829:   (ignoring any parameters) that is either <code>text/xml</code>,
1.22 avankest 830:   <code>application/xml</code>, or ends in <code>+xml</code>, it
 831:   <em class="ct">must</em> be an object that implements the
 832:   <code>Document</code> interface representing the parsed document. If
 833:   <code>Content-Type</code> did not contain such a media type, or if the
 834:   document could not be parsed (due to an XML well-formedness error or
 835:   unsupported character encoding, for instance), it <em class="ct">must</em>
 836:   be <code>null</code>.</p>
1.12 avankest 837: 
1.8 avankest 838:   <p>Its initial value <em class="ct">must</em> be <code>null</code>.</p>
1.5 avankest 839:  </dd>
1.12 avankest 840: 
1.22 avankest 841:  <dt><dfn id="dfn-status"><code>status</code></dfn> of type <code>unsigned
 842:  short</code>, readonly</dt>
1.12 avankest 843: 
1.5 avankest 844:  <dd>
 845:   <p>If the <code>status</code> attribute is not available an
1.22 avankest 846:   <code>INVALID_STATE_ERR</code> exception <em class="ct">must</em> be raised.
1.25 avankest 847:   It <em class="ct">must</em> be available when the state is
 848:   <span title="receiving state">receiving</span> or
 849:   <span title="loaded state">loaded</span>. When available, it
 850:   <em class="ct">must</em> represent the HTTP status code (typically
 851:   <code>200</code> for a successful connection).</p>
1.27 avankest 852: 
1.8 avankest 853:   <p>Its initial value <em class="ct">must</em> be <code>0</code>.</p>
1.12 avankest 854:  </dd>
 855: 
1.5 avankest 856:  <dt><dfn id="dfn-statustext"><code>statusText</code></dfn> of type
1.22 avankest 857:  <code>DOMString</code>, readonly</dt>
1.12 avankest 858: 
1.5 avankest 859:  <dd>
 860:   <p>If the <code>statusText</code> attribute is not available an
1.22 avankest 861:   <code>INVALID_STATE_ERR</code> exception <em class="ct">must</em> be raised.
1.25 avankest 862:   It <em class="ct">must</em> be available when the state is
 863:   <span title="receiving state">receiving</span> or
 864:   <span title="loaded state">loaded</span>). When available, it
 865:   <em class="ct">must</em> represent the HTTP status text sent by the server
 866:   (appears after the status code).</p>
1.21 avankest 867: 
1.8 avankest 868:   <p>Its initial value <em class="ct">must</em> be the empty string.</p>
1.1 avankest 869:  </dd>
 870:  </dl>
1.12 avankest 871: 
1.1 avankest 872:  <p>HTTP requests sent from multiple different <code>XMLHttpRequest</code>
1.22 avankest 873:  objects in succession <em class="ct">should</em> be pipelined into shared HTTP
 874:  connections.</p>
1.12 avankest 875: 
1.31 avankest 876:  <h3 id="events">Events for the <code title="">XMLHttpRequest</code>
 877:  Object</h3>
1.12 avankest 878: 
1.1 avankest 879:  <p>These sections describe the various events that can be dispatched on the
1.22 avankest 880:  object implementing the <code>XMLHttpRequest</code> interface. For this
 881:  version of the specification only one event is defined.</p>
1.12 avankest 882: 
1.1 avankest 883:  <dl>
 884:  <dt><dfn id="dfn-readystatechange"><code>readystatechange</code></dfn></dt>
1.24 avankest 885: 
1.1 avankest 886:  <dd>The <code>readystatechange</code> event <em class="ct">must</em> be
1.22 avankest 887:  dispatched when <code>readyState</code> changes value. It <em class="ct">must
 888:  not</em> bubble, <em class="ct">must not</em> be cancelable and
 889:  <em class="ct">must</em> implement the <code>Event</code> interface
1.37 ! avankest 890:  [<cite><span>DOM3Events</span></cite>]. The event has no namespace
1.22 avankest 891:  (<code>Event.namespaceURI</code> is <code>null</code>).</dd>
1.1 avankest 892:  </dl>
1.32 avankest 893: 
1.31 avankest 894:  <h3 id="exceptions">Exceptions for the <code title="">XMLHttpRequest</code>
 895:  Object</h3>
 896: 
1.32 avankest 897:  <pre class="idl">exception <dfn>XMLHttpRequestException</dfn> {
1.31 avankest 898:  unsigned short   code;
 899: };
 900: const unsigned short <span>NETWORK_ERR</span> = 101;</pre>
 901: 
1.33 avankest 902:  <p>The <dfn id="network-err"><code>NETWORK_ERR</code></dfn> exception is
 903:  thrown when a network error occurs in synchronous requests. See the section
 904:  on <code>send()</code> for more details.</p>
1.31 avankest 905:  <!-- Other specifications should probably be able to reuse this... -->
1.11 avankest 906: 
1.29 avankest 907:  <h2 class="no-num" id="notcovered">Not in this Specification</h2>
 908: 
 909:  <p><em>This section is non normative.</em></p>
 910: 
 911:  <p>This specification does not include the following features that may or may
 912:  not be implemented by user agents:</p>
 913: 
 914:  <ul>
 915:  <li><code>load</code> event and <code>onload</code> attribute;</li>
 916:  <li><code>error</code> event and <code>onerror</code> attribute;</li>
 917:  <li><code>progress</code> event and <code>onprogress</code> attribute;</li>
 918:  <li><code title="">abort</code> event and <code>onabort</code> attribute;</li>
 919:  <li>Timers have been suggested, perhaps an <code>ontimeout</code>
 920:   attribute;</li>
 921:  <li>Property to disable following redirects;</li>
1.30 avankest 922:  <li><code title="">responseXML</code> for <code>text/html</code>
 923:  documents;</li>
 924:  <li>Cross-site <code title="">XMLHttpRequest</code>.</li>
1.29 avankest 925:  </ul>
 926: 
1.1 avankest 927:  <h2 class="no-num" id="bibref">References</h2>
1.11 avankest 928: 
1.6 avankest 929:  <dl>
1.37 ! avankest 930:  <dt>[<dfn id="DOM3">DOM3Core</dfn>]</dt>
1.24 avankest 931: 
1.11 avankest 932:  <dd><cite><a href="http://www.w3.org/TR/DOM-Level-3-Core">Document Object
 933:   Model (DOM) Level 3 Core Specification</a></cite>, A. Le Hors, P. Le
 934:   Hégaret, L. Wood, G. Nicol, J. Robie, M. Champion, S. Byrne, editors.
 935:   World Wide Web Consortium, April 2004.</dd>
 936: 
1.37 ! avankest 937:  <dt>[<dfn id="DOM3EV">DOM3Events</dfn>]</dt>
1.24 avankest 938: 
1.1 avankest 939:  <dd><cite><a href="http://www.w3.org/TR/DOM-Level-3-Events/">Document Object
1.11 avankest 940:   Model (DOM) Level 3 Events Specification</a></cite>, Björn Höhrmann, editor.
 941:   World Wide Web Consortium, April 2006.</dd>
 942: 
1.37 ! avankest 943:  <dt>[<dfn id="ref-ecmascript">ECMAScript</dfn>]</dt>
1.24 avankest 944: 
1.14 avankest 945:  <dd><cite><a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMAScript
 946:   Language Specification</a></cite>, Third Edition. ECMA, December 1999.</dd>
 947: 
1.37 ! avankest 948:  <dt>[<dfn id="ref-rfc2046">RFC2046</dfn>]</dt>
1.24 avankest 949: 
1.19 avankest 950:  <dd><cite><a href="http://ietf.org/rfc/rfc2046">Multipurpose Internet Mail
 951:   Extensions (MIME) Part Two: Media Types</a></cite>, N. Freed, N. Borenstein,
 952:   editors. IETF, November 1996.</dd>
1.14 avankest 953: 
1.37 ! avankest 954:  <dt>[<dfn id="ref-rfc2109">RFC2109</dfn>]</dt>
1.24 avankest 955: 
1.11 avankest 956:  <dd><cite><a href="http://ietf.org/rfc/rfc2109">HTTP State Management
 957:   Mechanism</a></cite>, D. Kristol, L. Montulli, editors. IETF, February
 958:   1997.</dd>
 959: 
1.37 ! avankest 960:  <dt>[<dfn id="RFC2119">RFC2119</dfn>]</dt>
1.24 avankest 961: 
1.11 avankest 962:  <dd><cite><a href="http://ietf.org/rfc/rfc2119">RFC 2119: Key words
 963:   for use in RFCs to Indicate Requirement Levels</a></cite>, S. Bradner.
 964:   IETF, March 1997.</dd>
1.12 avankest 965: 
1.37 ! avankest 966:  <dt>[<dfn id="RFC2616">RFC2616</dfn>]</dt>
1.24 avankest 967: 
1.11 avankest 968:  <dd><cite><a href="http://ietf.org/rfc/rfc2616">Hypertext Transfer Protocol
 969:   -- HTTP/1.1</a></cite>, R. Fielding, J. Gettys, J. Mogul, H. Frystyk, L.
 970:   Masinter, P. Leach, T. Berners-Lee, editors. IETF, June 1999</dd>
1.12 avankest 971: 
1.37 ! avankest 972:  <dt>[<dfn id="ref-rfc2617">RFC2617</dfn>]</dt>
1.24 avankest 973: 
1.11 avankest 974:  <dd><cite><a href="http://ietf.org/rfc/rfc2617">HTTP Authentication: Basic
1.14 avankest 975:   and Digest Access Authentication</a></cite>, ...</dd>
1.12 avankest 976: 
1.37 ! avankest 977:  <dt>[<dfn id="ref-rfc2965">RFC2965</dfn>]</dt>
1.24 avankest 978: 
1.19 avankest 979:  <dd><cite><a href="http://ietf.org/rfc/rfc2965">HTTP State Management
 980:   Mechanism</a></cite>, D. Kristol, L. Montulli, editors. IETF, October
 981:   2000.</dd>
 982: 
1.37 ! avankest 983:  <dt>[<dfn id="ref-rfc3986">RFC3986</dfn>]</dt>
1.24 avankest 984: 
1.11 avankest 985:  <dd><cite><a href="http://ietf.org/rfc/rfc3986">Uniform Resource Identifier
 986:   (URI): Generic Syntax</a></cite>, T. Berners-Lee, R. Fielding, L. Masinter,
 987:   editors. IETF, January 2005.</dd>
1.28 avankest 988: 
1.37 ! avankest 989:   <dt>[<dfn id="ref-window">Window</dfn>]</dt>
1.28 avankest 990: 
 991:   <dd><cite><a href="http://www.w3.org/TR/Window/">Window Object
 992:   1.0</a></cite>, I. Davis, M. Stachowiak, editors. W3C, April 2006.</dd>
1.1 avankest 993:  </dl>
1.11 avankest 994: 
1.1 avankest 995:  <h2 class="no-num" id="acknowledgements">Acknowledgements</h2>
1.11 avankest 996: 
1.1 avankest 997:  <p><em>This section is non-normative</em></p>
1.12 avankest 998: 
1.7 avankest 999:  <p>The editor would like to thank to the following people who have contributed
1.33 avankest 1000:  to this specification (ordered by first name):</p>
1.12 avankest 1001: 
1.1 avankest 1002:  <ul>
1.22 avankest 1003:  <li>Alex Hopmann</li>
1.7 avankest 1004:  <li>Alex Vincent</li>
1.15 avankest 1005:  <li>Alexey Proskuryakov</li>
1.1 avankest 1006:  <li>Asbjørn Ulsberg</li>
 1007:  <li>Boris Zbarsky</li>
 1008:  <li>Björn Höhrmann</li>
 1009:  <li>Cameron McCormack</li>
 1010:  <li>Christophe Jolif</li>
 1011:  <li>Charles McCathieNevile</li>
 1012:  <li>Dean Jackson</li>
 1013:  <li>Doug Schepers</li>
 1014:  <li>Douglas Livingstone</li>
 1015:  <li>Gorm Haug Eriksen</li>
 1016:  <li>Hallvord R. M. Steen</li>
 1017:  <li>Håkon Wium Lie</li>
 1018:  <li>Ian Davis</li>
 1019:  <li>Ian Hickson</li>
 1020:  <li>Ivan Herman</li>
 1021:  <li>Jens Lindström</li>
 1022:  <li>Jim Deegan</li>
 1023:  <li>Jim Ley</li>
 1024:  <li>Jonas Sicking</li>
 1025:  <li>Julian Reschke</li>
 1026:  <li>Karl Dubost</li>
 1027:  <li>Maciej Stachowiak</li>
1.7 avankest 1028:  <li>Magnus Kristiansen</li>
1.1 avankest 1029:  <li>Marc Hadley</li>
 1030:  <li>Mark Nottingham</li>
 1031:  <li>Pawel Glowacki</li>
1.24 avankest 1032:  <li>Q42</li>
1.1 avankest 1033:  <li>Robin Berjon</li>
 1034:  <li>Ruud Steltenpool</li>
1.33 avankest 1035:  <li>Simon Pieters</li>
1.1 avankest 1036:  </ul>
1.12 avankest 1037: 
1.1 avankest 1038:  <p>Special thanks to the Microsoft employees who first implemented the
1.22 avankest 1039:  <code>XMLHttpRequest</code> interface, which was first widely deployed by the
 1040:  Windows Internet Explorer browser.</p>
1.12 avankest 1041: 
1.1 avankest 1042:  <p>Special thanks also to the WHATWG for drafing a first version of this
1.22 avankest 1043:  specification in their Web Applications 1.0 document.</p>
1.12 avankest 1044: 
1.1 avankest 1045:  <p>Thanks also to all those who have helped to improve this specification by
1.22 avankest 1046:  sending suggestions and corrections. (Please, keep bugging us with your
 1047:  issues!)</p>
1.29 avankest 1048: 
1.1 avankest 1049: </body>
 1050: </html>

Webmaster

AltStyle によって変換されたページ (->オリジナル) /