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