Annotation of 2006/webapi/XMLHttpRequest/Overview.src.html, revision 1.142
1.60 avankest 1: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
1.1 avankest 2: <html lang="en-US">
 3: <head>
 4:  <title>The XMLHttpRequest Object</title>
1.16 avankest 5:  <style type="text/css">
1.117 avankest 6:  pre.idl { border:solid thin; background:#eee; color:#000; padding:0.5em }
1.16 avankest 7:  pre.idl :link, pre.idl :visited { color:inherit; background:transparent }
1.58 avankest 8:  pre code { color:inherit; background:transparent }
1.16 avankest 9:  div.example { margin-left:1em; padding-left:1em; border-left:double; color:#222; background:#fcfcfc }
1.89 avankest 10:  .note { margin-left:2em; font-weight:bold; font-style:italic; color:#008000 }
1.16 avankest 11:  p.note::before { content:"Note: " }
1.89 avankest 12:  .issue { padding:.5em; border:solid #f00 }
1.16 avankest 13:  p.issue::before { content:"Issue: " }
1.119 avankest 14:  dl.switch { padding-left:2em }
 15:  dl.switch dt { text-indent:-1.5em }
 16:  dl.switch dt:before { content:'21円AA'; padding:0 0.5em 0 0; display:inline-block; width:1em; text-align:right; line-height:0.5em }
1.16 avankest 17:  em.ct { text-transform:lowercase; font-variant:small-caps; font-style:normal }
 18:  dfn { font-weight:bold; font-style:normal }
 19:  code { color:orangered }
 20:  code :link, code :visited { color:inherit }
1.122 avankest 21:  h1 code, h2 code, h3 code { color:inherit; background:inherit; font:inherit }
1.16 avankest 22:  </style>
1.7 avankest 23:  <link rel="stylesheet" href="http://www.w3.org/StyleSheets/TR/base">
1.120 avankest 24:  <link rel="stylesheet" href="http://www.w3.org/StyleSheets/TR/W3C-WD">
1.1 avankest 25: </head>
 26: <body>
 27:  <div class="head">
 28:  <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 29: 
1.10 avankest 30:  <h1 class="head">The <code title="">XMLHttpRequest</code> Object</h1>
1.12 avankest 31: 
1.127 avankest 32:  <h2 class="no-num no-toc" id="pagesubtitle">Editor's draft<!--W3C Working Draft--> [DATE: 3 August 2002]</h2>
1.12 avankest 33: 
1.1 avankest 34:  <dl>
1.10 avankest 35:   <dt>This Version:</dt>
1.47 avankest 36:   <dd><a href="[VERSION]/">http://www.w3.org/TR/[YEAR]/WD-XMLHttpRequest-[CDATE]/</a></dd>
1.14 avankest 37: 
1.10 avankest 38:   <dt>Latest Version:</dt>
1.1 avankest 39:   <dd><a href="http://www.w3.org/TR/XMLHttpRequest/">http://www.w3.org/TR/XMLHttpRequest/</a></dd>
1.14 avankest 40: 
1.10 avankest 41:   <dt>Previous Versions:</dt>
1.133 avankest 42:   <dd><a href="http://www.w3.org/TR/2007/WD-XMLHttpRequest-20070618/">http://www.w3.org/TR/2007/WD-XMLHttpRequest-20070618/</a></dd>
1.58 avankest 43:   <dd><a href="http://www.w3.org/TR/2007/WD-XMLHttpRequest-20070227/">http://www.w3.org/TR/2007/WD-XMLHttpRequest-20070227/</a></dd>
1.22 avankest 44:   <dd><a href="http://www.w3.org/TR/2006/WD-XMLHttpRequest-20060927/">http://www.w3.org/TR/2006/WD-XMLHttpRequest-20060927/</a></dd>
1.1 avankest 45:   <dd><a href="http://www.w3.org/TR/2006/WD-XMLHttpRequest-20060619/">http://www.w3.org/TR/2006/WD-XMLHttpRequest-20060619/</a></dd>
 46:   <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 47: 
1.1 avankest 48:   <dt>Editor:</dt>
 49:   <dd><a href="http://annevankesteren.nl/">Anne van Kesteren</a>
 50:   (<a href="http://www.opera.com/">Opera Software ASA</a>)
 51:   <<a href="mailto:annevk@opera.com">annevk@opera.com</a>></dd>
 52:  </dl>
1.14 avankest 53: 
1.1 avankest 54:  <p class="copyright"><a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a>
1.51 avankest 55:  © 2007
 56:  <a href="http://www.w3.org/"><acronym title="World Wide Web Consortium">W3C</acronym></a><sup>®</sup>
 57:  (<a href="http://www.csail.mit.edu/"><acronym title="Massachusetts Institute of Technology">MIT</acronym></a>,
 58:  <a href="http://www.ercim.org/"><acronym title="European Research Consortium for Informatics and Mathematics">ERCIM</acronym></a>,
 59:  <a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C
 60:  <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
 61:  <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>
 62:  and
 63:  <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document
 64:  use</a> rules apply.</p>
1.1 avankest 65:  </div>
1.12 avankest 66: 
1.1 avankest 67:  <hr>
1.12 avankest 68: 
1.1 avankest 69:  <h2 class="no-num no-toc" id="specabstract">Abstract</h2>
1.10 avankest 70: 
1.22 avankest 71:  <p>The <code title="">XMLHttpRequest</code> Object specification defines an
 72:  <abbr title="Application Programming Interface">API</abbr> that provides
 73:  scripted client functionality for transferring data between a client and a
 74:  server.</p>
1.12 avankest 75: 
1.1 avankest 76:  <h2 class="no-num no-toc" id="sotd">Status of this Document</h2>
1.12 avankest 77: 
1.1 avankest 78:  <p><em>This section describes the status of this document at the time of its
1.36 avankest 79:  publication. Other documents may supersede this document. A list of current
 80:  W3C publications and the latest revision of this technical report can be
 81:  found in the <a href="http://www.w3.org/TR/">W3C technical reports index</a>
1.117 avankest 82:  at http://www.w3.org/TR/.</em></p>
1.36 avankest 83: 
1.63 avankest 84:  <!-- change back to Last Call -->
1.127 avankest 85:  <p>This is the [DATE: 3 August 2002] <strong>Editor's</strong> <!--Working-->
 86:  Draft of The <code title="">XMLHttpRequest</code> Object specification. Please
 87:  send comments to
1.47 avankest 88:  <a href="mailto:public-webapi@w3.org">public-webapi@w3.org</a>
 89:  (<a href="http://lists.w3.org/Archives/Public/public-webapi/">archived</a>)
 90:  with either <samp>[XHR]</samp> or <samp title="">[XMLHttpRequest]</samp> at
1.63 avankest 91:  the start of the subject line<!-- by 2 April 2007-->.</p>
1.51 avankest 92: 
1.47 avankest 93:  <p>This document is produced by the
 94:  <a href="http://www.w3.org/2006/webapi/">Web API Working Group</a>, part of
 95:  the <a href="http://www.w3.org/2006/rwc/Activity">Rich Web Clients
 96:  Activity</a> in the W3C <a href="http://www.w3.org/Interaction/">Interaction
1.51 avankest 97:  Domain</a>. Changes made to this document can be found in the
1.47 avankest 98:  <a href="http://dev.w3.org/cvsweb/2006/webapi/XMLHttpRequest/Overview.html">W3C
1.117 avankest 99:  public CVS server</a>.</p>
1.12 avankest 100: 
1.1 avankest 101:  <p>Publication as a Working Draft does not imply endorsement by the W3C
1.36 avankest 102:  Membership. This is a draft document and may be updated, replaced or
 103:  obsoleted by other documents at any time. It is inappropriate to cite this
 104:  document as other than work in progress.</p>
1.12 avankest 105: 
1.1 avankest 106:  <p>This document was produced by a group operating under the
1.36 avankest 107:  <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February
1.52 avankest 108:  2004 W3C Patent Policy</a>. W3C maintains a
1.36 avankest 109:  <a rel="disclosure" href="http://www.w3.org/2004/01/pp-impl/38482/status">public
 110:  list of any patent disclosures</a> made in connection with the deliverables
 111:  of the group; that page also includes instructions for disclosing a patent.
 112:  An individual who has actual knowledge of a patent which the individual
 113:  believes contains
 114:  <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential
 115:  Claim(s)</a> must disclose the information in accordance with
 116:  <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section
 117:  6 of the W3C Patent Policy</a>.</p>
1.12 avankest 118: 
1.1 avankest 119:  <h2 class="no-num no-toc" id="toc">Table of Contents</h2>
1.21 avankest 120: 
1.1 avankest 121:  <!--toc-->
1.12 avankest 122: 
1.1 avankest 123:  <h2 id="introduction">Introduction</h2>
1.12 avankest 124: 
1.1 avankest 125:  <p><em>This section is non-normative.</em></p>
1.12 avankest 126: 
1.33 avankest 127:  <p>The <code>XMLHttpRequest</code> object implements an interface exposed by
 128:  a scripting engine that allows scripts to perform HTTP client functionality,
1.22 avankest 129:  such as submitting form data or loading data from a server.</p>
1.24 avankest 130: 
1.1 avankest 131:  <p>The name of the object is <code>XMLHttpRequest</code> for compatibility
1.127 avankest 132:  with the Web, though each component of this name is potentially misleading.
1.39 avankest 133:  First, the object supports any text based format, including XML. Second, it
 134:  can be used to make requests over both HTTP and HTTPS (some implementations
 135:  support protocols in addition to HTTP and HTTPS, but that functionality is
 136:  not covered by this specification). Finally, it supports "requests" in a
 137:  broad sense of the term as it pertains to HTTP; namely all activity involved
 138:  with HTTP requests or responses for the defined HTTP methods.</p>
1.12 avankest 139: 
1.1 avankest 140:  <h3 id="examples">Examples of Usage</h3>
1.12 avankest 141: 
1.1 avankest 142:  <p><em>This section is non-normative.</em></p>
1.12 avankest 143: 
1.37 avankest 144:  <p>Some [<cite><span>ECMAScript</span></cite>] examples
1.32 avankest 145:  are listed in the specification. In addition, you can find some below.</p>
1.14 avankest 146: 
 147:  <div class="example">
 148:  <p>Some simple code to do something with data from an XML document fetched
1.22 avankest 149:  over the network:</p>
1.16 avankest 150: 
1.58 avankest 151:  <pre><code>function test(data) {
1.14 avankest 152: // taking care of data
 153: }
 154: 
 155: function handler() {
1.117 avankest 156: if(this.readyState == 4 && this.status == 200) {
1.14 avankest 157:  // so far so good
1.117 avankest 158:  if(this.responseXML != null && this.responseXML.getElementById('test').firstChild.data)
 159:   // success!
1.14 avankest 160:  test(this.responseXML.getElementById('test').firstChild.data);
 161:  else
 162:  test(null);
1.117 avankest 163: } else if (this.readyState == 4 && this.status != 200) {
1.14 avankest 164:  // fetched the wrong page or network error...
 165:  test(null);
 166: }
 167: }
1.12 avankest 168: 
1.14 avankest 169: var client = new XMLHttpRequest();
 170: client.onreadystatechange = handler;
 171: client.open("GET", "test.xml");
1.58 avankest 172: client.send();</code></pre>
1.16 avankest 173: 
1.56 avankest 174:  <p>If you just want to log a message to the server:</p>
1.16 avankest 175: 
1.58 avankest 176:  <pre><code>function log(message) {
1.14 avankest 177: var client = new XMLHttpRequest();
1.56 avankest 178: client.open("POST", "/log");
1.57 avankest 179: client.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
1.14 avankest 180: client.send(message);
1.58 avankest 181: }</code></pre>
1.16 avankest 182: 
1.14 avankest 183:  <p>Or if you want to check the status of a document on the server:</p>
1.16 avankest 184: 
1.58 avankest 185:  <pre><code>function fetchStatus(address) {
1.14 avankest 186: var client = new XMLHttpRequest();
 187: client.onreadystatechange = function() {
 188:  // in case of network errors this might not give reliable results
 189:  if(this.readyState == 4)
 190:  returnStatus(this.status);
 191: }
 192: client.open("HEAD", address);
 193: client.send();
1.58 avankest 194: }</code></pre>
1.14 avankest 195:  </div>
1.12 avankest 196: 
1.1 avankest 197:  <h3 id="conformance">Conformance</h3>
1.12 avankest 198: 
1.27 avankest 199:  <p>Everything in this specification is normative except for diagrams,
 200:  examples, notes and sections marked non-normative.</p>
1.12 avankest 201: 
1.1 avankest 202:  <p>The key words <em class="ct">must</em>, <em class="ct">must not</em>,
1.74 avankest 203:  <em class="ct">should</em> and <em class="ct">may</em> in this document are
 204:  to be interpreted as described in RFC 2119.
 205:  [<cite><span>RFC2119</span></cite>]</p>
1.12 avankest 206: 
1.1 avankest 207:  <p>This specification defines the following classes of products:</p>
1.12 avankest 208: 
1.1 avankest 209:  <dl>
1.74 avankest 210:  <dt><dfn id="conforming-user-agent">Conforming user agent</dfn></dt>
1.24 avankest 211: 
1.74 avankest 212:  <dd>
 213:   <p>A user agent <em class="ct">must</em> behave as described in this
1.106 avankest 214:   specification in order to be considered conformant.</p>
1.95 avankest 215: 
1.140 avankest 216:   <p>If the user agent is not a conforming XML user agent the <span>XML
 217:   response entity body</span> <em class="ct">must</em> (always) be
 218:   <code>null</code>.</p>
 219: 
 220:   <p>User agents <em class="ct">may</em> implement algorithms given in
 221:   this specification in any way desired, so long as the end result is
 222:   indistinguishable from the result that would be obtained by the
 223:   specification's algorithms.</p>
1.110 avankest 224: 
1.95 avankest 225:   <p class="note">This specification uses both the terms "conforming user
 226:   agent(s)" and "user agent(s)" to refer to this product class.</p>
1.74 avankest 227:  </dd>
1.110 avankest 228: 
1.94 avankest 229:  <dt><dfn id="conforming-xml-user-agent">Conforming XML user agent</dfn></dt>
1.110 avankest 230: 
1.140 avankest 231:  <dd><p>A user agent that is both a <span>conforming user agent</span> and
 232:  a conforming XML processor that reports violations of namespace
 233:  well-formedness. [<cite><span>XML</span></cite>]
 234:  [<cite><span>XMLNS</span></cite>]</p></dd>
1.1 avankest 235:  </dl>
1.32 avankest 236: 
1.30 avankest 237:  <h4 id="dependencies">Dependencies</h4>
1.33 avankest 238: 
1.29 avankest 239:  <p>This specification relies on several underlying specifications.</p>
 240:  <dl>
 241:  <dt>DOM</dt>
1.33 avankest 242: 
1.29 avankest 243:  <dd>
1.126 avankest 244:   <p>A <span title="conforming user agent">conforming user agent</span>
1.95 avankest 245:   <em class="ct">must</em> support some version of DOM Events and DOM Core,
 246:   because this specification uses some of the features defined in those
 247:   specifications. [<cite><span>DOM3Events</span></cite>]
 248:   [<cite><span>DOM3Core</span></cite>]</p>
 249: 
 250:   <p>It <em class="ct">must</em> also support some version of the Window
 251:   Object because some of the functionality in this specification relies on
 252:   it. [<cite><span>Window</span></cite>]</p>
1.29 avankest 253:  </dd>
 254: 
 255:  <dt>HTTP</dt>
1.33 avankest 256: 
1.29 avankest 257:  <dd>
1.126 avankest 258:   <p>A <span title="conforming user agent">conforming user agent</span>
 259:   <em class="ct">must</em> support some version of the HTTP protocol. It
 260:   <em class="ct">should</em> support any HTTP method that matches the
 261:   <span><code>Method</code> production</span> and <em class="ct">must</em> at
 262:   least support the following methods:</p>
1.58 avankest 263: 
 264:   <ul>
 265:   <li><code>GET</code></li>
 266:   <li><code>POST</code></li>
 267:   <li><code>HEAD</code></li>
 268:   <li><code>PUT</code></li>
 269:   <li><code>DELETE</code></li>
 270:   <li><code>OPTIONS</code></li>
 271:   </ul>
1.135 avankest 272: 
1.58 avankest 273:   <p>Other requirements regarding HTTP are made throughout the
1.39 avankest 274:   specification. [<cite><span>RFC2616</span></cite>]</p>
1.29 avankest 275:  </dd>
 276:  </dl>
1.12 avankest 277: 
1.80 avankest 278:  <h4 id="terminology">Terminology</h4>
1.12 avankest 279: 
1.80 avankest 280:  <p>There is a <dfn id="case-insensitive-match">case-insensitive match</dfn>
1.101 avankest 281:  of strings <var>s1</var> and <var>s2</var> if after uppercasing both strings
1.100 avankest 282:  (by mapping a-z to A-Z) they are identical.</p>
1.141 avankest 283:  
 284:  <p>Two URIs are <dfn id="same-origin">same-origin</dfn> if after
 285:  performing scheme-based normalization on both URIs as described in section
 286:  5.3.3 of RFC 3987 the scheme, domain and port components are
 287:  identical. [<cite><span>RFC3987</span></cite>]</p>
 288:  
 289:  <p class="issue">The above definition does not deal with data:,
 290:  javascript:, etc. What to do about those?</p>
1.80 avankest 291: 
 292:  <h4 id="extensibility">Extensibility</h4>
1.12 avankest 293: 
1.81 avankest 294:  <p>Extensions of the API defined by this specification are <em>strongly
1.22 avankest 295:  discouraged</em>. User agents, Working Groups and other interested parties
1.33 avankest 296:  should discuss extensions on a relevant public forum, preferably
1.22 avankest 297:  <a href="mailto:public-webapi@w3.org">public-webapi@w3.org</a>.</p>
1.12 avankest 298: 
 299:  <h2 id="xmlhttprequest">The <code title="">XMLHttpRequest</code> Object</h2>
 300: 
1.58 avankest 301:  <p>The <code>XMLHttpRequest</code> object can be used by scripts to
1.22 avankest 302:  programmatically connect to their originating server via HTTP.</p>
1.12 avankest 303: 
1.1 avankest 304:  <p>Objects implementing the <code>XMLHttpRequest</code> interface
1.22 avankest 305:  <em class="ct">must</em> also implement the <code>EventTarget</code>
1.58 avankest 306:  interface. [<cite><span>DOM3Events</span></cite>]</p>
1.12 avankest 307: 
1.58 avankest 308:  <p>Objects implementing the <code title="">Window</code> interface
 309:  <em class="ct">must</em> provide an <code title="">XMLHttpRequest()</code>
 310:  constructor. [<cite><span>Window</span></cite>]</p>
1.12 avankest 311: 
1.1 avankest 312:  <div class="example">
1.58 avankest 313:  <p>In ECMAScript this can be used as follows:</p>
 314: 
 315:  <pre><code>var client = new XMLHttpRequest();</code></pre>
1.1 avankest 316:  </div>
1.12 avankest 317: 
1.58 avankest 318:  <p>When the <code title="">XMLHttpRequest()</code> constructor is invoked a
 319:  persistent pointer to the associated <code title="">Window</code> object
 320:  <em class="ct">must</em> be stored on the newly created object. This is the
1.25 avankest 321:  <dfn title="Window pointer" id="window-pointer"><code>Window</code>
1.58 avankest 322:  pointer</dfn>. The associated <code title="">Window</code> object is the one
1.127 avankest 323:  of which the <code title="">XMLHttpRequest</code> constructor was invoked.
 324:  This <span title="Window pointer">pointer</span> <em class="ct">must</em>
 325:  persist even if the browsing context in which the <code title="">Window</code>
 326:  is located is destroyed (by removing it from a parent browsing context, for
 327:  instance).</p>
1.25 avankest 328: 
1.37 avankest 329:  <p>The term browsing context is defined by the <cite>Window Object
 330:  1.0</cite> specification. [<cite><span>Window</span></cite>]</p>
1.27 avankest 331: 
 332:  <!-- XXX if the document object changes in the browsing context you get an
1.33 avankest 333:  exception in some implementations. -->
1.27 avankest 334: 
1.58 avankest 335:  <div class="example">
1.65 avankest 336:  <p>If <var><code>win</code></var> is a <code title="">Window</code> object
 337:  <var><code>client</code></var> will have a pointer to
 338:  <var><code>win</code></var> in the following example:</p>
1.58 avankest 339: 
1.65 avankest 340:  <pre><code>var client = new win.XMLHttpRequest()</code></pre>
1.58 avankest 341:  </div>
1.12 avankest 342: 
1.58 avankest 343:  <pre class="idl">interface <dfn id="xmlhttprequest-object">XMLHttpRequest</dfn> {
 344:  // event handler
1.70 avankest 345:      attribute EventListener <span>onreadystatechange</span>;
1.58 avankest 346: 
 347:  // state
1.71 avankest 348:  const unsigned short <span title="UNSENT state">UNSENT</span> = 0;
1.134 avankest 349:  const unsigned short <span title="OPENED state">OPENED</span> = 1;
1.123 avankest 350:  const unsigned short <span title="HEADERS_RECEIVED state">HEADERS_RECEIVED</span> = 2;
1.86 avankest 351:  const unsigned short <span title="LOADING state">LOADING</span> = 3;
1.117 avankest 352:  const unsigned short <span title="DONE state">DONE</span> = 4;
1.70 avankest 353:  readonly attribute unsigned short <span>readyState</span>;
1.58 avankest 354: 
 355:  // request
1.70 avankest 356:  void <span>open</span>(in DOMString <var>method</var>, in DOMString <var>url</var>);
 357:  void <span>open</span>(in DOMString <var>method</var>, in DOMString <var>url</var>, in boolean <var>async</var>);
 358:  void <span>open</span>(in DOMString <var>method</var>, in DOMString <var>url</var>, in boolean <var>async</var>, in DOMString <var>user</var>);
 359:  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>);
 360:  void <span>setRequestHeader</span>(in DOMString <var>header</var>, in DOMString <var>value</var>);
 361:  void <span>send</span>();
 362:  void <span>send</span>(in DOMString <var>data</var>);
 363:  void <span>send</span>(in Document <var>data</var>);
 364:  void <span>abort</span>();
1.58 avankest 365: 
 366:  // response
1.70 avankest 367:  DOMString <span>getAllResponseHeaders</span>();
 368:  DOMString <span>getResponseHeader</span>(in DOMString <var>header</var>);
 369:  readonly attribute DOMString <span>responseText</span>;
 370:  readonly attribute Document <span>responseXML</span>;
 371:  readonly attribute unsigned short <span>status</span>;
 372:  readonly attribute DOMString <span>statusText</span>;
1.1 avankest 373: };</pre>
1.8 avankest 374: 
1.58 avankest 375:  <p>The <code>XMLHttpRequest</code> object can be in five states:
1.71 avankest 376:  <span title="UNSENT state">UNSENT</span>,
1.134 avankest 377:  <span title="OPENED state">OPENED</span>,
1.123 avankest 378:  <span title="HEADERS_RECEIVED state">HEADERS_RECEIVED</span>,
1.86 avankest 379:  <span title="LOADING state">LOADING</span> and
1.79 avankest 380:  <span title="DONE state">DONE</span>. The current state is exposed through
 381:  the <code>readyState</code> attribute. The method definitions below define
 382:  when a state transition takes place.</p>
1.58 avankest 383: 
 384:  <p>When constructed, the <code>XMLHttpRequest</code> object
1.71 avankest 385:  <em class="ct">must</em> be in the UNSENT state. This state is represented
1.134 avankest 386:  by the <dfn id="unsent-state" title="UNSENT state"><code>UNSENT</code></dfn>
1.58 avankest 387:  constant, whose value is <code>0</code>.</p>
 388: 
1.134 avankest 389:  <p>The OPENED state is the state of the object when the <code>open()</code>
1.92 avankest 390:  method has been successfully invoked. During this state request headers can
1.58 avankest 391:  be set using <code>setRequestHeader()</code> and the request can be made
 392:  using <code>send()</code>. This state is represented by the
1.134 avankest 393:  <dfn id="opened-state" title="OPENED state"><code>OPENED</code></dfn> constant,
1.131 avankest 394:  whose value is <code>1</code>.</p>
1.58 avankest 395: 
1.134 avankest 396:  <p>The OPENED state has an associated <dfn id="send-flag"><code>send()</code>
1.104 avankest 397:  flag</dfn> which can be either "true" or "false". The initial value of the
 398:  <code title="">send()</code> flag is "false".</p>
1.87 avankest 399: 
1.123 avankest 400:  <p>The HEADERS_RECEIVED state is the state of the object when all response
 401:  headers have been received. This state is represented by the
1.131 avankest 402:  <dfn id="headers-received-state" title="HEADERS_RECEIVED state"><code>HEADERS_RECEIVED</code></dfn>
1.123 avankest 403:  constant, whose value is <code>2</code>.</p>
 404: 
 405:  <p>The LOADING state is the state of the object when the response entity body
 406:  is being received. This state is represented by the
1.131 avankest 407:  <dfn id="loading-state" title="LOADING state"><code>LOADING</code></dfn> constant,
1.86 avankest 408:  whose value is <code>3</code>.</p>
1.58 avankest 409: 
1.79 avankest 410:  <p>The DONE state is the state of the object when either the data transfer
1.58 avankest 411:  has been completed or something went wrong during the transfer (infinite
 412:  redirects for instance). This state is represented by the
1.131 avankest 413:  <dfn id="done-state" title="DONE state"><code>DONE</code></dfn> constant,
 414:  whose value is <code>4</code>.</p>
1.90 avankest 415: 
1.124 avankest 416:  <p>The DONE state has an associated <dfn id="error-flag">error flag</dfn>
 417:  which can be either "true" or "false". The initial value of the error flag is
 418:  "false".</p>
 419: 
1.88 avankest 420:  <p>The <dfn id="response-entity-body">response entity body</dfn> is the
 421:  fragment of the <span>entity body</span> received so far (LOADING state) or
 422:  the complete entity body (DONE state). If there is no entity body the
 423:  response entity body is "null".</p>
 424: 
 425:  <p>The <dfn id="text-response-entity-body">text response entity body</dfn>
1.107 avankest 426:  is either a <code>DOMString</code> representing the <span>response entity
1.126 avankest 427:  body</span> or <code>null</code>. The text response entity body is the return
 428:  value of the following algorithm:</p>
1.90 avankest 429: 
1.88 avankest 430:  <ol>
1.107 avankest 431:  <li><p>If the response entity body is "null" return <code>null</code> and
 432:  terminate these steps.</p>
1.90 avankest 433: 
1.113 avankest 434:  <li><p>Let <var>charset</var> be "null".</p></li>
1.90 avankest 435: 
 436:  <li><p>If there is no <code>Content-Type</code> header or there is a
 437:  <code>Content-Type</code> header which contains a MIME type that is
1.116 avankest 438:  <code>text/xml</code>, <code>application/xml</code> or ends in
 439:  <code title="">+xml</code> (ignoring any parameters) use the rules set forth
1.126 avankest 440:  in the XML specifications to determine the character encoding. Let
1.116 avankest 441:  <var>charset</var> be the determined character encoding.</p></li>
1.90 avankest 442: 
1.142 ! avankest 443:  <li>
 ! 444:   <p>If there is a <code>Content-Type</code> header which contains a
 ! 445:   <code>text/html</code> MIME type follow the rules set forth in the HTML
 ! 446:   specification to determine the character encoding. Let
 ! 447:   <var>charset</var> be the determined character encoding.
 ! 448:   [<cite><span>HTML5</span></cite>]</p>
 ! 449: 
 ! 450:   <p class="note">If we get two interoperable implementations of all
 ! 451:   features in this specification and HTML5 has not yet reached
 ! 452:   recommendation status this feature will be made informative.</p>
 ! 453:  </li>
1.118 avankest 454: 
1.115 avankest 455:  <li>
1.140 avankest 456:   <p>If the MIME type specified by the <code>Content-Type</code> header
 457:   contains a <code>charset</code> parameter and <var>charset</var> is
 458:   "null" let <var>charset</var> be the value of that parameter.</p>
1.118 avankest 459: 
 460:   <p class="note">The algorithms described by the XML and HTML specifications
 461:   already take <code>Content-Type</code> into account.</p>
1.115 avankest 462:  </li>
1.118 avankest 463: 
1.111 avankest 464:  <li>
 465:   <!-- This stuff is copied from HTML5. Thanks Hixie! -->
1.113 avankest 466:   <p>If <var>charset</var> is "null" then, for each of the rows in the
1.127 avankest 467:   following table, starting with the first one and going down, if the first
 468:   bytes of <var>bytes</var> match the bytes given in the first column, then
 469:   let <var>charset</var> be the encoding given in the cell in the second
 470:   column of that row. If there is no match <var>charset</var> remains
 471:   "null".</p>
1.117 avankest 472: 
 473:   <table>
 474:   <thead>
 475:    <tr>
1.111 avankest 476:    <th>Bytes in Hexadecimal
 477:    <th>Description
1.117 avankest 478:   <tbody>
 479:    <tr>
1.111 avankest 480:    <td>00 00 FE FF
1.117 avankest 481:    <td>UTF-32BE BOM
 482:    <tr>
 483:    <td>FF FE 00 00
 484:    <td>UTF-32LE BOM
 485:    <tr>
 486:    <td>FE FF
 487:    <td>UTF-16BE BOM
 488:    <tr>
 489:    <td>FF FE
 490:    <td>UTF-16LE BOM
 491:    <tr>
 492:    <td>EF BB BF
 493:    <td>UTF-8 BOM<!-- nobody uses this
 494:    <tr>
 495:    <td>DD 73 66 73
 496:    <td>UTF-EBCDIC
 497: -->
 498:   </table>
1.111 avankest 499:  </li>
 500: 
1.113 avankest 501:  <li><p>If <var>charset</var> is "null" let <var>charset</var> be
 502:  UTF-8.</p></li>
 503: 
1.107 avankest 504:  <li><p>Return the result of decoding the response entity body using
 505:  <var>charset</var>. Or, if that fails, return <code>null</code>.</p></li>
1.88 avankest 506:  </ol>
1.90 avankest 507: 
1.88 avankest 508:  <p>The <dfn id="xml-response-entity-body">XML response entity body</dfn> is
1.107 avankest 509:  either a <code>Document</code> representing the <span>response entity
1.126 avankest 510:  body</span> or <code>null</code>. The XML response entity body is the return
 511:  value of the following algorithm:</p>
1.90 avankest 512: 
1.88 avankest 513:  <ol>
1.107 avankest 514:  <li><p>If the response entity body is "null" terminate these steps and
 515:  return <code>null</code>.</p></li>
1.88 avankest 516: 
1.103 avankest 517:  <li><p>If a <code>Content-Type</code> is present and it does not contain a
 518:  MIME type (ignoring any parameters) that is <code>text/xml</code>,
1.116 avankest 519:  <code>application/xml</code> or ends in <code title="">+xml</code> terminate
 520:  these steps and return <code>null</code>. (Do not terminate these steps if
 521:  there is no <code>Content-Type</code> header at all.)</p></li>
1.88 avankest 522: 
1.128 avankest 523:  <li>
 524:   <p>Parse the response entity body into a document tree following the
 525:   rules from the XML specifications. Let the result be <var>parsed
 526:   document</var>. If this fails (unsupported character encoding, namespace
 527:   well-formedness error et cetera) terminate these steps return
 528:   <code>null</code>. [<cite><span>XML</span></cite>]
 529:   [<cite><span>XMLNS</span></cite>]</p>
 530:   
 531:   <p class="note">Scripts in the resulting document tree will not be executed,
 532:   resources referenced will not be loaded and no associated XSLT will be
 533:   applied.</p>
 534:  </li>
1.88 avankest 535: 
1.96 avankest 536:  <li><p>Return an object implementing the <code>Document</code>
1.88 avankest 537:  interface representing the <var>parsed document</var>.</p></li>
 538:  </ol>
1.58 avankest 539: 
1.5 avankest 540:  <dl>
1.131 avankest 541:  <dt><dfn id="onreadystatechange"><code>onreadystatechange</code></dfn>
1.39 avankest 542:  of type <code>EventListener</code></dt>
1.12 avankest 543: 
1.1 avankest 544:  <dd>
 545:   <p>An attribute that takes an <code>EventListener</code> as value that
1.58 avankest 546:   <em class="ct">must</em> be invoked along with any other appropriate event
 547:   listeners that are registered on this object when a
1.87 avankest 548:   <code>readystatechange</code> event is dispatched on it during the
 549:   bubbling phase. Its initial value <em class="ct">must</em> be
 550:   <code>null</code>.</p>
1.1 avankest 551:  </dd>
1.12 avankest 552: 
1.131 avankest 553:  <dt><dfn id="readystate"><code>readyState</code></dfn> of type
1.22 avankest 554:  <code>unsigned short</code>, readonly</dt>
1.12 avankest 555: 
1.1 avankest 556:  <dd>
1.58 avankest 557:   <p>The attribute <em class="ct">must</em> be the value of the constant
 558:   corresponding to the object's current state.</p>
1.1 avankest 559:  </dd>
1.12 avankest 560: 
1.131 avankest 561:  <dt><dfn id="open" title="open"><code>open(<var>method</var>,
1.22 avankest 562:  <var>url</var>, <var>async</var>, <var>user</var>,
 563:  <var>password</var>)</code></dfn>, method</dt>
1.12 avankest 564: 
1.1 avankest 565:  <dd>
1.58 avankest 566:   <p>When invoked, the user agent <em class="ct">must</em> follow the
1.96 avankest 567:   following steps (unless otherwise indicated):</p>
1.58 avankest 568: 
 569:   <ol>
1.97 avankest 570:   <li><p>If the <var>method</var> argument does not match the
1.58 avankest 571:   <dfn><code>Method</code> production</dfn> defined in section 5.1.1 of RFC
1.98 avankest 572:   2616 raise a <code>SYNTAX_ERR</code> exception and terminate these steps.
1.58 avankest 573:   [<cite><span>RFC2616</span></cite>]</p></li>
 574: 
 575:   <li><p>If the given <var>method</var> is not supported for security
 576:   reasons the user agent <em class="ct">should</em> raise a
1.98 avankest 577:   <code>SECURITY_ERR</code> exception and terminate these steps.</p></li>
1.58 avankest 578: 
 579:   <li><p>Let <var>stored method</var> be <var>method</var>.</p></li>
 580: 
1.80 avankest 581:   <li><p>If <var>method</var>
 582:   <span title="case-insensitive match">case-insensitively matches</span>
 583:   <code>GET</code>, <code>POST</code>, <code>HEAD</code>, <code>PUT</code>,
1.96 avankest 584:   <code>DELETE</code> or <code>OPTIONS</code> convert it to its uppercase
 585:   equivalent (by mapping a-z to A-Z) and let <var>stored method</var> be
 586:   the result.</p></li>
1.68 avankest 587:   <!-- WebKit (and supposedly Firefox) also uppercase: CONNECT, COPY,
 588:   INDEX, LOCK, M-POST, MKCOL, MOVE, PROPFIND, PROPPATCH, TRACE and UNLOCK.
 589:   Not sure if TRACE and CONNECT are worth it though. They raise a
 590:   SECURITY_ERR exception anyway... -->
1.58 avankest 591: 
 592:   <li><p>Drop the fragment identifier (if any) from <var>url</var> and let
 593:   <var>stored url</var> be the result of that operation.</p></li>
 594: 
1.96 avankest 595:   <li><p>If <var>stored url</var> is a relative reference resolve it using
 596:   the current value of the <code>baseURI</code> attribute of the
 597:   <code>Document</code> object currently associated with the
 598:   <span><code>Window</code> pointer</span>. If this fails raise a
1.98 avankest 599:   <code>SYNTAX_ERR</code> exception and terminate these steps.</p></li>
1.58 avankest 600: 
1.101 avankest 601:   <li><p>If <var>stored url</var> contains an unsupported scheme raise a
 602:   <code>NOT_SUPPORTED_ERR</code> and terminate these steps.</p></li>
1.110 avankest 603: 
1.58 avankest 604:   <li><p>If the <code>"user:password"</code> format in the
1.141 avankest 605:   <code>userinfo</code> production defined in section 3.2.1 of RFC 3986
 606:   is not supported for the relevant scheme and <var>stored url</var>
 607:   contains this format raise a <code>SYNTAX_ERR</code> and terminate
 608:   these steps. [<cite><span>RFC3986</span></cite>]</p></li>
1.58 avankest 609: 
 610:   <li><p>If <var>stored url</var> contains the <code>"user:password"</code>
 611:   format let <var>stored user</var> be the user part and <var>stored
 612:   password</var> be the password part.</p></li>
 613: 
 614:   <li><p>If <var>stored url</var> just contains the <code>"user"</code>
 615:   format let <var>stored user</var> be the user part.</p></li>
 616: 
1.69 avankest 617:   <li>
1.141 avankest 618:    <p>If <var>stored url</var> is not of the <span>same-origin</span> as
 619:    the URI specified by the <code>baseURI</code> attribute of the
 620:    <code>document</code> attribute of the <span><code>Window</code>
 621:    pointer</span> the user agent <em class="ct">should</em> raise a
 622:    <code>SECURITY_ERR</code> exception and terminate these steps.</p>
1.69 avankest 623:   </li>
1.58 avankest 624: 
 625:   <li><p>Let <var>async</var> be the value of the <var>async</var> argument
1.102 avankest 626:   or <code>true</code> if it was omitted.</p></li>
1.58 avankest 627: 
1.126 avankest 628:   <li><p>If the <var>user</var> argument was not omitted, and its syntax
 629:   does not match that specified by the relevant authentication scheme, raise
1.98 avankest 630:   a <code>SYNTAX_ERR</code> exception and terminate these steps.</p></li>
1.14 avankest 631: 
1.58 avankest 632:   <li>
 633:    <p>If the <var>user</var> argument was not omitted and is not
 634:    <code>null</code> let <var>stored user</var> be <var>user</var> encoded
 635:    using the encoding specified in the relevant authentication scheme or
 636:    UTF-8 if the scheme fails to specify an encoding.</p>
1.14 avankest 637: 
1.58 avankest 638:    <p class="note">This step overrides any user that may have been set by
 639:    the <var>url</var> argument.</p>
 640:   </li>
1.16 avankest 641: 
1.58 avankest 642:   <li><p>If the <var>user</var> argument was not omitted and is
 643:   <code>null</code> remove <var>stored user</var>.</p></li>
1.14 avankest 644: 
1.58 avankest 645:   <li><p>If the <var>password</var> argument was not omitted and its syntax
1.96 avankest 646:   does not match that specified by the relevant authentication scheme raise
1.98 avankest 647:   a <code>SYNTAX_ERR</code> exception and terminate these steps.</p></li>
1.58 avankest 648: 
 649:   <li><p>If the <var>password</var> argument was not omitted and is not
 650:   <code>null</code> let <var>stored password</var> be <var>password</var>
 651:   encoded using the encoding specified in the relevant authentication
 652:   scheme or UTF-8 if the scheme fails to specify an encoding.</p></li>
 653: 
 654:   <li><p>If the <var>password</var> argument was not omitted and is
 655:   <code>null</code> remove <var>stored password</var>.</p></li>
 656: 
1.108 avankest 657:   <li><p><span title="abort send()">Abort the <code>send()</code>
 658:   algorithm</span>, set <span>response entity body</span> to "null" and
 659:   reset the list of request headers.<p></li>
1.58 avankest 660: 
1.108 avankest 661:   <li><p>The user agent <em class="ct">should</em> cancel any network
 662:   activity for which the object is responsible.</p></li>
1.58 avankest 663:   <!-- we can hardly require it... -->
 664: 
1.134 avankest 665:   <li><p>Switch the object to the <span title="OPENED state">OPENED</span>
1.105 avankest 666:   state, set the <span><code>send()</code> flag</span> to "false" and then
1.104 avankest 667:   synchronously dispatch a <code>readystatechange</code> event on the
 668:   object and return the method call.</p></li>
1.58 avankest 669:   </ol>
1.14 avankest 670: 
1.19 avankest 671:   <p class="note">A future version or extension of this specification will
1.33 avankest 672:   most likely define a way of doing cross-site requests.</p>
1.1 avankest 673:  </dd>
1.12 avankest 674: 
1.131 avankest 675:  <dt><dfn id="setrequestheader" title="setrequestheader"><code>setRequestHeader(<var>header</var>,
1.22 avankest 676:  <var>value</var>)</code></dfn>, method</dt>
1.12 avankest 677: 
1.5 avankest 678:  <dd>
1.45 avankest 679:   <p>Each request has a list of request headers with associated values. This
 680:   method can be used to manipulate those values and set new request
 681:   headers.</p>
 682: 
1.58 avankest 683:   <p>When invoked, the user agent <em class="ct">must</em> follow the
1.96 avankest 684:   following steps (unless otherwise indicated):</p>
1.14 avankest 685: 
1.58 avankest 686:   <ol>
 687:   <li><p>If the state of the object is not
1.134 avankest 688:   <span title="OPENED state">OPENED</span> raise an
1.98 avankest 689:   <code>INVALID_STATE_ERR</code> exception and terminate these
 690:   steps.</p></li>
1.96 avankest 691: 
 692:   <li><p>If the <span><code>send()</code> flag</span> is "true" raise an
1.98 avankest 693:   <code>INVALID_STATE_ERR</code> exception and terminate these
 694:   steps.</p></li>
1.14 avankest 695: 
1.97 avankest 696:   <li><p>If the <var>header</var> argument does not match the
1.22 avankest 697:   <dfn><code>field-name</code> production</dfn> as defined by section 4.2
1.96 avankest 698:   of RFC 2616 or is <code>null</code> raise a <code>SYNTAX_ERR</code>
1.98 avankest 699:   exception and terminate these steps.
1.96 avankest 700:   [<cite><span>RFC2616</span></cite>]</p></li>
 701: 
1.98 avankest 702:   <li><p>If the <var>value</var> argument is <code>null</code> terminate
 703:   these steps. (Do not raise an exception.)</li>
1.70 avankest 704:   <!-- undefined is to be treated as null here... -->
1.79 avankest 705: 
1.97 avankest 706:   <li><p>If the <var>value</var> argument does not match the
1.22 avankest 707:   <dfn><code>field-value</code> production</dfn> as defined by section 4.2
1.98 avankest 708:   of RFC 2616 raise a <code>SYNTAX_ERR</code> and terminate these steps.
1.58 avankest 709:   [<cite><span>RFC2616</span></cite>]</p></li>
1.14 avankest 710: 
1.32 avankest 711:   <li>
1.132 avankest 712:    <p>For security reasons, these steps <em class="ct">should</em> be
1.98 avankest 713:    terminated if the <var>header</var> argument
1.80 avankest 714:    <span title="case-insensitive match">case-insensitively matches</span>
 715:    one of the following headers:</p>
1.58 avankest 716: 
1.32 avankest 717:    <ul>
 718:    <li><code>Accept-Charset</code></li>
 719:    <li><code>Accept-Encoding</code></li>
1.68 avankest 720:    <li><code>Connection</code></li>
1.32 avankest 721:    <li><code>Content-Length</code></li>
1.68 avankest 722:    <li><code>Content-Transfer-Encoding</code></li>
 723:    <li><code>Date</code></li>
1.32 avankest 724:    <li><code>Expect</code></li>
 725:    <li><code>Host</code></li>
 726:    <li><code>Keep-Alive</code></li>
 727:    <li><code>Referer</code></li>
 728:    <li><code>TE</code></li>
 729:    <li><code>Trailer</code></li>
 730:    <li><code>Transfer-Encoding</code></li>
 731:    <li><code>Upgrade</code></li>
1.68 avankest 732:    <li><code>Via</code></li>
1.32 avankest 733:    </ul>
 734:   </li>
1.132 avankest 735:   
 736:   <li><p>Also for security reasons, these steps <em class="ct">should</em> be
 737:   terminated if the first six characters of the <var>header</var> argument
 738:   <span title="case-insensitive match">case-insensitively match</span>
 739:   <code>Proxy-</code>.</p></li>
1.5 avankest 740: 
1.58 avankest 741:   <li><p>If the <var>header</var> argument is not in the list of request
1.96 avankest 742:   headers append the <var>header</var> with its associated <var>value</var>
1.98 avankest 743:   to the list and terminate these steps.</p></li>
1.58 avankest 744: 
 745:   <li><p>If the <var>header</var> argument is in the list of request
1.96 avankest 746:   headers either use multiple headers, combine the values or use a
 747:   combination of those (section 4.2, RFC 2616).
 748:   [<cite><span>RFC2616</span></cite>]</p></li>
 749:   <!-- XXX it seems UAs always combine the values -->
1.58 avankest 750:   </ol>
1.45 avankest 751: 
 752:   <p class="note">See also the <code>send()</code> method regarding user
1.71 avankest 753:   agent header handling for caching, authentication, proxies, and
 754:   cookies.</p>
1.14 avankest 755: 
 756:   <div class="example">
1.58 avankest 757:   <pre><code>// The following script:
1.14 avankest 758: var client = new XMLHttpRequest();
 759: client.open('GET', 'demo.cgi');
 760: client.setRequestHeader('X-Test', 'one');
 761: client.setRequestHeader('X-Test', 'two');
 762: client.send();
 763: 
 764: // ...would result in the following header being sent:
 765: ...
 766: X-Test: one, two
1.58 avankest 767: ...</code></pre>
1.14 avankest 768:   </div>
1.5 avankest 769:  </dd>
1.12 avankest 770: 
1.131 avankest 771:  <dt><dfn id="send" title="send"><code>send(<var>data</var>)</code></dfn>,
1.22 avankest 772:  method</dt>
1.12 avankest 773: 
1.17 avankest 774:  <dd>
1.58 avankest 775:   <p>The <code>send()</code> method initiates the request and its optional
1.106 avankest 776:   argument provides the <span>entity body</span>. Authors are strongly
 777:   encouraged to ensure that they have specified the
 778:   <code>Content-Type</code> header via <code>setRequestHeader()</code>
 779:   before invoking <code>send()</code> with a non-<code>null</code>
 780:   <var>data</var> argument.</p>
1.58 avankest 781: 
 782:   <p>When invoked, the user agent <em class="ct">must</em> follow the
1.108 avankest 783:   following steps (unless otherwise noted). Note that this algorithm might
1.126 avankest 784:   get aborted if the <code>open()</code> or <code>abort()</code> method is
 785:   invoked. When the
1.109 avankest 786:   <dfn title="abort send()" id="abort-send-algorithm"><code>send()</code>
1.110 avankest 787:   algorithm is aborted</dfn> the user agent <em class="ct">must</em>
 788:   terminate the algorithm after finishing the step it is on.</p>
 789: 
1.108 avankest 790:   <p class="note">The following algorithm can not be aborted through script
 791:   when <var>async</var> is <code>false</code>. It can only be aborted when
 792:   <var>async</var> is <code>true</code> and only after the method call has
 793:   returned.</p>
1.58 avankest 794: 
 795:   <ol>
 796:   <li><p>If the state of the object is not
1.134 avankest 797:   <span title="OPENED state">OPENED</span> raise an
1.98 avankest 798:   <code>INVALID_STATE_ERR</code> exception and terminate these
 799:   steps.</p></li>
1.96 avankest 800: 
 801:   <li><p>If the <span><code>send()</code> flag</span> is "true" raise an
1.98 avankest 802:   <code>INVALID_STATE_ERR</code> exception and terminate these
 803:   steps.</p></li>
1.58 avankest 804: 
1.102 avankest 805:   <li><p>If <var>async</var> is <code>true</code> set the
1.103 avankest 806:   <span><code>send()</code> flag</span> to "true".</p></li>
 807: 
1.58 avankest 808:   <li>
 809:    <p>If the <var>data</var> argument has not been omitted and is not
1.131 avankest 810:    <code>null</code> use it for the <dfn id="entity-body">entity body</dfn>
 811:    as defined by section 7.2 of RFC 2616 observing the following rules:
 812:    [<cite><span>RFC2616</span></cite>]</p>
1.58 avankest 813: 
1.119 avankest 814:    <dl class="switch">
1.58 avankest 815:    <dt><var>data</var> is a <code>DOMString</code></dt>
 816: 
1.96 avankest 817:    <dd><p>Encode <var>data</var> using UTF-8 for transmission.</p></dd>
1.58 avankest 818: 
 819:    <dt><var>data</var> is a <code>Document</code>
 820: 
 821:    <dd>
1.96 avankest 822:     <p>Serialize <var>data</var> into a namespace well-formed XML document
 823:     and encoded using the encoding given by
 824:     <code><var>data</var>.xmlEncoding</code>, if specified, or UTF-8
 825:     otherwise. Or, if this fails because the <code>Document</code>
 826:     cannot be serialized act as if <var>data</var> is
 827:     <code>null</code>.</p>
 828: 
 829:     <p>If no <code>Content-Type</code> header is in the list of request
1.126 avankest 830:     headers append a <code>Content-Type</code> header to the list of request
 831:     headers with a value of <code>application/xml</code>.</p>
1.58 avankest 832: 
 833:     <p class="note">Subsequent changes to the <code>Document</code> have
 834:     no effect on what is submitted.</p>
 835:    </dd>
 836: 
 837:    <dt><var>data</var> is not a <code>DOMString</code> or
 838:    <code>Document</code></dt>
 839: 
1.96 avankest 840:    <dd><p>Use the stringification mechanisms of the host language on
 841:    <var>data</var> and treat the result as if <var>data</var> is a
 842:    <code>DOMString</code>. Or, if this fails, act as if <var>data</var> is
 843:    <code>null</code>.</p></dd>
1.58 avankest 844:    </dl>
 845: 
1.126 avankest 846:    <p>If the <var>data</var> argument has been omitted, or is
 847:    <code>null</code>, no entity body is used in the request.</p>
1.58 avankest 848:   </li>
 849: 
1.71 avankest 850:   <li><p>Make a request to <var>stored url</var>, using HTTP method
 851:   <var>stored method</var>, user <var>stored user</var> (if provided) and
 852:   password <var>stored password</var> (if provided), taking into account
 853:   the entity body, list of request headers and the rules listed directly
 854:   after this set of steps.</p></li>
1.60 avankest 855: 
1.67 avankest 856:   <li>
1.96 avankest 857:    <p>Synchronously dispatch a <code>readystatechange</code> event on the
 858:    object.</p>
1.67 avankest 859: 
1.96 avankest 860:    <p class="note">The state of the object does not change. The event is
 861:    dispatched for historical reasons.</p>
1.67 avankest 862:   </li>
 863: 
1.102 avankest 864:   <li><p>If <var>async</var> is <code>true</code> return the
1.98 avankest 865:   <code>send()</code> method call. (Do not terminate the steps in the
 866:   algorithm though.)</p></li>
1.58 avankest 867: 
1.117 avankest 868:   <li>
1.123 avankest 869:    <p>While downloading the resource the following rules are to be
 870:    observed.</p>
 871: 
1.119 avankest 872:    <dl class="switch">
1.118 avankest 873:    <dt>If the response is an HTTP redirect</dt>
 874:    
 875:    <dd>
 876:     <p>If the redirect does not violate security or infinite loop
 877:     precautions and the scheme is supported transparently follow it and go
 878:     to the start of this step.</p>
 879:     
 880:     <p class="note">HTTP places requirements on the user agent regarding the
 881:     preservation of the request method and entity body during redirects, and
 882:     also requires users to be notified of certain kinds of automatic
 883:     redirections.</p>
 884:     <!-- Arguably HTTP should be fixed for the latter case. No browser
 885:     follows that as far as I know. -->
 886: 
 887:     <p>Otherwise, follow the following set of steps:</p>
 888:     
 889:     <ol>
1.124 avankest 890:     <li><p>Set the <span>response entity body</span> to "null", the
 891:     <span>error flag</span> to "true" and reset the list of request
 892:     headers.</p></li>
1.118 avankest 893: 
 894:     <li><p>Synchronously switch the state to
 895:     <span title="DONE state">DONE</span>.</p></li>
 896: 
 897:     <li><p>If <var>async</var> is set to <code>false</code> raise a
 898:     <code>NETWORK_ERR</code> exception and terminate the overall
 899:     algorithm.</p></li>
 900: 
 901:     <li><p>Synchronously dispatch a <code>readystatechange</code> event on
 902:     the object.</p></li>
 903: 
 904:     <li><p>Terminate the overall algorithm.</p></li>
 905:     </ol>
 906: 
 907:     <p class="note">It is likely that a future version of the
 908:     <code>XMLHttpRequest</code> object will dispatch an <code>error</code>
 909:     event here as well.</p>
 910:    </dd>
1.117 avankest 911: 
1.121 avankest 912: 
1.118 avankest 913:    <dt>If the user cancels the download</dt>
1.58 avankest 914: 
1.118 avankest 915:    <dd>
 916:     <p>Run the following set of steps:</p>
1.60 avankest 917: 
1.118 avankest 918:     <ol>
1.124 avankest 919:     <li><p>Set the <span>response entity body</span> to "null", the
 920:     <span>error flag</span> to "true" and reset the list of request
 921:     headers.</p></li>
1.118 avankest 922: 
 923:     <li><p>Synchronously switch the state to
 924:     <span title="DONE state">DONE</span>.</p></li>
 925: 
1.121 avankest 926:     <li><p>If <var>async</var> is set to <code>false</code> raise an
 927:     <code>ABORT_ERR</code> exception and terminate the overall
1.118 avankest 928:     algorithm.</p></li>
 929: 
 930:     <li><p>Synchronously dispatch a <code>readystatechange</code> event on
 931:     the object.</p></li>
 932: 
 933:     <li><p>Terminate the overall algorithm.</p></li>
 934:     </ol>
1.121 avankest 935: 
1.118 avankest 936:     <p class="note">It is likely that a future version of the
1.121 avankest 937:     <code>XMLHttpRequest</code> object will dispatch an
 938:     <code title="">abort</code> event here as well.</p>
1.118 avankest 939:    </dd>
1.60 avankest 940: 
1.121 avankest 941: 
1.118 avankest 942:    <dt>In case of network errors</dt>
1.60 avankest 943: 
1.118 avankest 944:    <dd>
1.126 avankest 945:     <p>In case of DNS errors, or other type of network errors, run the
 946:     following set of steps. <span class="note">This does not include HTTP
 947:     responses that indicate some type of error, such as HTTP status code
 948:     410.</span></p>
1.118 avankest 949: 
 950:     <ol>
1.124 avankest 951:     <li><p>Set the <span>response entity body</span> to "null", the
 952:     <span>error flag</span> to "true" and reset the list of request
 953:     headers.</p></li>
1.118 avankest 954: 
 955:     <li><p>Synchronously switch the state to
 956:     <span title="DONE state">DONE</span>.</p></li>
 957: 
 958:     <li><p>If <var>async</var> is set to <code>false</code> raise a
 959:     <code>NETWORK_ERR</code> exception and terminate the overall
 960:     algorithm.</p></li>
 961: 
 962:     <li><p>Synchronously dispatch a <code>readystatechange</code> event on
 963:     the object.</p></li>
 964: 
 965:     <li><p>Terminate the overall algorithm.</p></li>
 966:     </ol>
 967: 
 968:     <p class="note">It is likely that a future version of the
 969:     <code>XMLHttpRequest</code> object will dispatch an <code>error</code>
 970:     event here as well.</p>
 971:    </dd>
 972:    
 973:    <dt>Once all HTTP headers have been received</dt>
 974:    
 975:    <dd>
 976:     <p>If all HTTP headers have been received, before receiving the message
1.123 avankest 977:     body (if any), run the following steps:</p>
1.60 avankest 978: 
1.118 avankest 979:     <ol>
 980:     <li><p>Synchronously switch the state to
1.123 avankest 981:     <span title="HEADERS_RECEIVED state">HEADERS_RECEIVED</span>.</p></li>
1.118 avankest 982: 
 983:     <li><p>Synchronously dispatch a <code>readystatechange</code> event on
 984:     the object.</p></li>
1.123 avankest 985:     </ol>
 986:    </dd>
 987:    
 988:    <dt>Once the first byte (or more) of the response entity body has been
 989:    received</dt>
 990:    <dt>If there is no response entity body</dt>
 991:    
 992:    <dd>
 993:     <p>Once the first byte of the response entity body has been received or
 994:     in case there is no response entity body, run the following steps:</p>
 995:     
 996:     <ol>
1.118 avankest 997:     <li><p>Synchronously switch the state to
 998:     <span title="LOADING state">LOADING</span>.</p></li>
 999: 
 1000:     <li><p>Synchronously dispatch a <code>readystatechange</code> event on
 1001:     the object.</p></li>
 1002:     </ol>
 1003:    </dd>
 1004:    </dl>
 1005:    
1.124 avankest 1006:    <p>Finally, once the complete resource has been downloaded go to the next
1.118 avankest 1007:    step.</p>
1.58 avankest 1008:   </li>
 1009: 
1.82 avankest 1010:   <li><p>When the request has successfully completed loading, synchronously
1.96 avankest 1011:   switch the state to <span title="DONE state">DONE</span> and then
 1012:   synchronously dispatch a <code>readystatechange</code> event on the
 1013:   object and return the method call in case of <var>async</var> being
 1014:   <code>false</code>.</p></li>
1.58 avankest 1015:   </ol>
1.14 avankest 1016: 
1.91 avankest 1017:   <p>If the user agent allows the user to configure a proxy it
1.22 avankest 1018:   <em class="ct">should</em> modify the request appropriately;
1.42 avankest 1019:   <abbr title="in other words">i.e.</abbr>, connect to the proxy host
 1020:   instead of the origin server, modify the <code>Request-Line</code> and
 1021:   send <code>Proxy-Authorization</code> headers as specified.</p>
1.12 avankest 1022: 
1.42 avankest 1023:   <p>If the user agent supports HTTP Authentication it
1.22 avankest 1024:   <em class="ct">should</em> consider requests originating from this object
1.42 avankest 1025:   to be part of the protection space that includes the accessed URIs and
 1026:   send <code>Authorization</code> headers and handle <code>401
1.137 avankest 1027:   Unauthorized</code> requests appropriately. If authentication fails, user
1.42 avankest 1028:   agents <em class="ct">should</em> prompt the users for credentials.
 1029:   [<cite><span>RFC2617</span></cite>]</p>
 1030: 
1.57 avankest 1031:   <p>If the user agent supports HTTP State Management it
1.42 avankest 1032:   <em class="ct">should</em> persist, discard and send cookies (as received
 1033:   in the <code>Set-Cookie</code> and <code>Set-Cookie2</code> response
 1034:   headers, and sent in the <code>Cookie</code> header) as applicable.
 1035:   [<cite><span>RFC2965</span></cite>]</p>
 1036: 
 1037:   <p>If the user agent implements a HTTP cache it <em class="ct">should</em>
 1038:   respect <code>Cache-Control</code> request headers set by the script
 1039:   (<abbr title="for example">e.g.</abbr>, <code>Cache-Control:
 1040:   no-cache</code> bypasses the cache). It <em class="ct">must not</em> send
 1041:   <code>Cache-Control</code> or <code>Pragma</code> request headers
1.137 avankest 1042:   automatically unless the user explicitly requests such behavior
1.42 avankest 1043:   (<abbr>e.g.</abbr>, by (force-)reloading the page). <code>304 Not
1.22 avankest 1044:   Modified</code> responses that are a result of a user agent generated
 1045:   conditional request <em class="ct">must</em> be presented as <code>200
1.57 avankest 1046:   OK</code> responses with the appropriate content. The user agent
1.39 avankest 1047:   <em class="ct">must</em> allow scripts to override automatic cache
1.22 avankest 1048:   validation by setting request headers (e.g., <code>If-None-Match</code>,
1.42 avankest 1049:   <code>If-Modified-Since</code>), in which case <code>304 Not
 1050:   Modified</code> responses <em class="ct">must</em> be passed through.
 1051:   [<cite><span>RFC2616</span></cite>]</p>
1.12 avankest 1052: 
1.8 avankest 1053:   <p>If the user agent implements server-driven content-negotiation
1.42 avankest 1054:   it <em class="ct">should</em> set <code>Accept-Language</code>,
1.22 avankest 1055:   <code>Accept-Encoding</code> and <code>Accept-Charset</code> headers as
 1056:   appropriate; it <em class="ct">must not</em> automatically set the
 1057:   <code>Accept</code> header. Responses to such requests
1.127 avankest 1058:   <em class="ct">must</em> have the content-encodings automatically
1.42 avankest 1059:   decoded. [<cite><span>RFC2616</span></cite>]</p>
1.8 avankest 1060:  </dd>
1.12 avankest 1061: 
1.131 avankest 1062:  <dt><dfn id="abort"><code>abort()</code></dfn>, method</dt>
1.12 avankest 1063: 
1.5 avankest 1064:  <dd>
1.60 avankest 1065:   <p>When invoked, the user agent <em class="ct">must</em> run the following
1.96 avankest 1066:   steps (unless otherwise noted):</p>
1.60 avankest 1067: 
 1068:   <ol>
1.108 avankest 1069:   <li><p><span title="abort send()">Abort the <code>send()</code>
 1070:   algorithm</span>, set the <span>response entity body</span> to "null",
1.135 avankest 1071:   the <span>error flag</span> to "true" and remove any registered request
 1072:   headers.</p></li>
1.60 avankest 1073: 
1.108 avankest 1074:   <li><p>The user agent <em class="ct">should</em> cancel any network
 1075:   activity for which the object is responsible.</p></li>
1.60 avankest 1076: 
1.83 avankest 1077:   <li>
1.85 avankest 1078:    <p>If the state is <span title="UNSENT state">UNSENT</span>,
1.134 avankest 1079:    <span title="OPENED state">OPENED</span> and the <span><code>send()</code>
1.87 avankest 1080:    flag</span> is "false", or <span title="DONE state">DONE</span> go to
 1081:    the next step.</p>
1.85 avankest 1082: 
1.135 avankest 1083:    <p>Otherwise, switch the state to
 1084:    <span title="DONE state">DONE</span>, set the
 1085:    <span><code>send()</code> flag</span> to "false" and synchronously
 1086:    dispatch a <code>readystatechange</code> event on the object.</p>
1.83 avankest 1087:   </li>
1.67 avankest 1088: 
1.60 avankest 1089:   <li>
1.97 avankest 1090:    <p>Switch the state to <span title="UNSENT state">UNSENT</span>. (Do not
1.71 avankest 1091:    dispatch the <code>readystatechange</code> event.)</p>
1.60 avankest 1092: 
1.82 avankest 1093:    <p class="note">It is likely that a future version of the
 1094:    <code>XMLHttpRequest</code> object will dispatch an
 1095:    <code title="">abort</code> event here as well.</p>
1.60 avankest 1096:   </li>
 1097:   </ol>
1.5 avankest 1098:  </dd>
1.12 avankest 1099: 
1.131 avankest 1100:  <dt><dfn id="getallresponseheaders"><code>getAllResponseHeaders()</code></dfn>,
1.22 avankest 1101:  method</dt>
1.12 avankest 1102: 
1.5 avankest 1103:  <dd>
1.60 avankest 1104:   <p>When invoked, the user agent <em class="ct">must</em> run
1.58 avankest 1105:   the following steps:</p>
 1106: 
 1107:   <ol>
1.124 avankest 1108:   <li><p>If the state is <span title="UNSENT state">UNSENT</span> or
1.134 avankest 1109:   <span title="OPENED state">OPENED</span> raise an
1.98 avankest 1110:   <code>INVALID_STATE_ERR</code> exception and terminate these
 1111:   steps.</p></li>
1.124 avankest 1112:   
 1113:   <li><p>If the <span>error flag</span> is "true" return <code>null</code>
 1114:   and terminate these steps.</p></li>
1.96 avankest 1115: 
 1116:   <li><p>Return all the HTTP headers, as a single string, with each header
 1117:   line separated by a U+000D CR U+000A LF pair excluding the status
 1118:   line.</p></li>
1.58 avankest 1119:   </ol>
1.24 avankest 1120: 
1.5 avankest 1121:   <div class="example">
1.58 avankest 1122:   <pre><code>// The following script:
1.5 avankest 1123: var client = new XMLHttpRequest();
1.14 avankest 1124: client.open("GET", "test.txt", true);
1.5 avankest 1125: client.send();
1.12 avankest 1126: client.onreadystatechange = function() {
1.13 avankest 1127: if(this.readyState == 3) {
1.12 avankest 1128:  print(this.getAllResponseHeaders());
 1129: }
 1130: }
1.5 avankest 1131: 
 1132: // ...should output something similar to the following text:
 1133: Date: 2004年10月24日 04:58:38 GMT
 1134: Server: Apache/1.3.31 (Unix)
 1135: Keep-Alive: timeout=15, max=99
 1136: Connection: Keep-Alive
 1137: Transfer-Encoding: chunked
1.58 avankest 1138: Content-Type: text/plain; charset=utf-8</code></pre>
1.5 avankest 1139:   </div>
 1140:  </dd>
1.12 avankest 1141: 
1.131 avankest 1142:  <dt><dfn id="getresponseheader" title="getresponseheader"><code>getResponseHeader(<var>header</var>)</code></dfn>,
1.22 avankest 1143:  method</dt>
1.12 avankest 1144: 
1.1 avankest 1145:  <dd>
1.58 avankest 1146:   <p>When the method is invoked, the user agent <em class="ct">must</em> run
 1147:   the following steps:</p>
1.14 avankest 1148: 
1.58 avankest 1149:   <ol>
1.124 avankest 1150:   <li><p>If the state is <span title="UNSENT state">UNSENT</span> or
1.134 avankest 1151:   <span title="OPENED state">OPENED</span> raise an
1.98 avankest 1152:   <code>INVALID_STATE_ERR</code> exception and terminate these
 1153:   steps.</p></li>
1.58 avankest 1154: 
1.124 avankest 1155:   <li><p>If the <span>error flag</span> is "true" return <code>null</code>
 1156:   and terminate these steps.</p></li>
 1157: 
1.97 avankest 1158:   <li><p>If the <var>header</var> argument does not match the
1.96 avankest 1159:   <span><code>field-name</code> production</span> raise a
1.98 avankest 1160:   <code>SYNTAX_ERR</code> exception and terminate these steps.</p></li>
1.58 avankest 1161: 
1.80 avankest 1162:   <li><p>If the <var>header</var> argument
 1163:   <span title="case-insensitive match">case-insensitively matches</span>
1.127 avankest 1164:   multiple HTTP headers for the last request sent, return the values of
1.96 avankest 1165:   these headers as a single concatenated string separated from each other
1.98 avankest 1166:   by an U+002C COMMA followed by an U+0020 SPACE and terminate these
1.96 avankest 1167:   steps.</p></li>
1.58 avankest 1168: 
1.80 avankest 1169:   <li><p>If the <var>header</var> argument
 1170:   <span title="case-insensitive match">case-insensitively matches</span> a
1.96 avankest 1171:   single HTTP header for the last request sent return the value of that
1.98 avankest 1172:   header and terminate these steps.</p></li>
1.58 avankest 1173: 
1.96 avankest 1174:   <li><p>Return <code>null</code>.</p></li>
1.58 avankest 1175:   </ol>
1.12 avankest 1176: 
1.1 avankest 1177:   <div class="example">
1.58 avankest 1178:   <pre><code>// The following script:
1.1 avankest 1179: var client = new XMLHttpRequest();
1.14 avankest 1180: client.open("GET", "test.txt", true);
1.5 avankest 1181: client.send();
1.12 avankest 1182: client.onreadystatechange = function() {
1.13 avankest 1183: if(this.readyState == 3) {
1.14 avankest 1184:  print(client.getResponseHeader("Content-Type"));
1.12 avankest 1185: }
 1186: }
1.1 avankest 1187: 
1.5 avankest 1188: // ...should output something similar to the following text:
1.58 avankest 1189: Content-Type: text/plain; charset=utf-8</code></pre>
1.1 avankest 1190:   </div>
1.5 avankest 1191:  </dd>
1.12 avankest 1192: 
1.131 avankest 1193:  <dt><dfn id="responsetext"><code>responseText</code></dfn> of type
1.22 avankest 1194:  <code>DOMString</code>, readonly</dt>
1.12 avankest 1195: 
1.5 avankest 1196:  <dd>
1.88 avankest 1197:   <p>On getting, the user agent <em class="ct">must</em> run the following
 1198:   steps:</p>
 1199: 
 1200:   <ol>
 1201:   <li><p>If the state is not <span title="LOADING state">LOADING</span> or
1.96 avankest 1202:   <span title="DONE state">DONE</span> raise an
1.98 avankest 1203:   <code>INVALID_STATE_ERR</code> exception and terminate these
 1204:   steps.</p></li>
1.12 avankest 1205: 
1.88 avankest 1206:   <li><p>Return the <span>text response entity body</span>.</p></li>
 1207:   </ol>
1.5 avankest 1208:  </dd>
1.12 avankest 1209: 
1.131 avankest 1210:  <dt><dfn id="responsexml"><code>responseXML</code></dfn> of type
1.22 avankest 1211:  <code>Document</code>, readonly</dt>
1.12 avankest 1212: 
1.8 avankest 1213:  <dd>
1.75 avankest 1214:   <p>On getting, the user agent <em class="ct">must</em> run the following
 1215:   steps:</p>
1.79 avankest 1216: 
1.75 avankest 1217:   <ol>
1.96 avankest 1218:   <li><p>If the state is not <span title="DONE state">DONE</span> raise an
1.98 avankest 1219:   <code>INVALID_STATE_ERR</code> exception and terminate these
 1220:   steps.</p></li>
1.75 avankest 1221: 
1.88 avankest 1222:   <li><p>Return the <span>XML response entity body</span>.</p></li>
1.75 avankest 1223:   </ol>
1.5 avankest 1224:  </dd>
1.12 avankest 1225: 
1.131 avankest 1226:  <dt><dfn id="status"><code>status</code></dfn> of type <code>unsigned
1.22 avankest 1227:  short</code>, readonly</dt>
1.12 avankest 1228: 
1.5 avankest 1229:  <dd>
1.72 avankest 1230:   <p>On getting, if available, it <em class="ct">must</em> return the HTTP
 1231:   status code sent by the server (typically <code>200</code> for a
 1232:   successful request). Otherwise, if not available, the user agent
 1233:   <em class="ct">must</em> raise an <code>INVALID_STATE_ERR</code>
 1234:   exception.</p>
1.12 avankest 1235:  </dd>
 1236: 
1.131 avankest 1237:  <dt><dfn id="statustext"><code>statusText</code></dfn> of type
1.22 avankest 1238:  <code>DOMString</code>, readonly</dt>
1.12 avankest 1239: 
1.5 avankest 1240:  <dd>
1.72 avankest 1241:   <p>On getting, if available, it <em class="ct">must</em> return the HTTP
 1242:   status text sent by the server (appears after the status code). Otherwise,
 1243:   if not available, the user agent <em class="ct">must</em> raise an
 1244:   <code>INVALID_STATE_ERR</code> exception.</p>
1.1 avankest 1245:  </dd>
 1246:  </dl>
1.12 avankest 1247: 
1.121 avankest 1248: 
1.31 avankest 1249:  <h3 id="events">Events for the <code title="">XMLHttpRequest</code>
 1250:  Object</h3>
1.12 avankest 1251: 
1.134 avankest 1252:  <p>This section describes the various events that can be dispatched on
 1253:  objects implementing the <code>XMLHttpRequest</code> interface. For this
1.22 avankest 1254:  version of the specification only one event is defined.</p>
1.12 avankest 1255: 
1.1 avankest 1256:  <dl>
1.131 avankest 1257:  <dt><dfn id="readystatechange"><code>readystatechange</code></dfn></dt>
1.24 avankest 1258: 
1.72 avankest 1259:  <dd>When the user agent dispatches a <code title="">readystatechange</code>
 1260:  event (as indicated above) it <em class="ct">must not</em> bubble,
 1261:  <em class="ct">must not</em> be cancelable and <em class="ct">must</em>
 1262:  implement the <code>Event</code> interface. Its <code>namespaceURI</code>
 1263:  attribute <em class="ct">must</em> be <code>null</code>.
 1264:  [<cite><span>DOM3Events</span></cite>]</dd>
1.1 avankest 1265:  </dl>
1.32 avankest 1266: 
1.31 avankest 1267:  <h3 id="exceptions">Exceptions for the <code title="">XMLHttpRequest</code>
 1268:  Object</h3>
1.138 avankest 1269:  
 1270:  <p>Several algorithms in this specification may result in an exception
 1271:  being thrown. These exceptions are all part of the group
 1272:  <code>ExceptionCode</code> and use the <code>DOMException</code> object
 1273:  which is defined in DOM Level 3 Core. In addition this specification
 1274:  extends the <code>ExceptionCode</code> group with several new
 1275:  constants as indicated below. [<cite><span>DOM3Core</span></cite>]</p>
1.31 avankest 1276: 
1.138 avankest 1277:  <pre class="idl">const unsigned short <span>SECURITY_ERR</span> = 18;
1.121 avankest 1278: const unsigned short <span>NETWORK_ERR</span> = 101;
 1279: const unsigned short <span>ABORT_ERR</span> = 102;</pre>
1.31 avankest 1280: 
1.138 avankest 1281:  <p>The <dfn id="security-err"><code>SECURITY_ERR</code></dfn> exception is
 1282:  raised if an attempt is made to perform an operation or access some data
 1283:  in a way that would be a security risk or a violation of the user agent's
 1284:  security policy.</p>
 1285: 
 1286:  <!-- http://lists.w3.org/Archives/Public/public-webapi/2006May/0027.html -->
 1287: 
 1288:  <p class="note">The <code title="">SECURITY_ERR</code> exception is
 1289:  expected to be eventually folded into an update of the the DOM Level 3
 1290:  Core specification with an equivalent definition and identical constant
 1291:  value. Until that happens it is defined here to guide implementors. (This
 1292:  is also the reason it has a different constant value from the other
 1293:  exceptions.)</p>
 1294: 
1.33 avankest 1295:  <p>The <dfn id="network-err"><code>NETWORK_ERR</code></dfn> exception is
1.138 avankest 1296:  raised when a network error occurs in synchronous requests.</p>
1.121 avankest 1297: 
1.138 avankest 1298:  <p>The <dfn id="abort-err"><code>ABORT_ERR</code></dfn> exception is
 1299:  raised when the user aborts a request in synchronous requests.</p>
1.121 avankest 1300: 
 1301: 
1.11 avankest 1302: 
1.29 avankest 1303:  <h2 class="no-num" id="notcovered">Not in this Specification</h2>
 1304: 
 1305:  <p><em>This section is non normative.</em></p>
 1306: 
1.72 avankest 1307:  <p>This specification does not include the following features which are
 1308:  being considered for a future version of this specification:</p>
1.29 avankest 1309: 
 1310:  <ul>
 1311:  <li><code>load</code> event and <code>onload</code> attribute;</li>
 1312:  <li><code>error</code> event and <code>onerror</code> attribute;</li>
 1313:  <li><code>progress</code> event and <code>onprogress</code> attribute;</li>
 1314:  <li><code title="">abort</code> event and <code>onabort</code> attribute;</li>
 1315:  <li>Timers have been suggested, perhaps an <code>ontimeout</code>
 1316:   attribute;</li>
 1317:  <li>Property to disable following redirects;</li>
1.30 avankest 1318:  <li><code title="">responseXML</code> for <code>text/html</code>
 1319:  documents;</li>
1.40 avankest 1320:  <li>Cross-site <code title="">XMLHttpRequest</code>;</li>
1.87 avankest 1321:  <li><code>responseBody</code> to deal with byte streams;</li>
1.114 avankest 1322:  <li><code>overrideMimeType</code> to fix up MIME types;</li>
1.87 avankest 1323:  <li><code>getRequestHeader()</code> and
 1324:  <code>removeRequestHeader()</code>.</li>
1.29 avankest 1325:  </ul>
 1326: 
1.1 avankest 1327:  <h2 class="no-num" id="bibref">References</h2>
1.11 avankest 1328: 
1.6 avankest 1329:  <dl>
1.37 avankest 1330:  <dt>[<dfn id="DOM3">DOM3Core</dfn>]</dt>
1.24 avankest 1331: 
1.11 avankest 1332:  <dd><cite><a href="http://www.w3.org/TR/DOM-Level-3-Core">Document Object
1.92 avankest 1333:  Model (DOM) Level 3 Core Specification</a></cite>, A. Le Hors, P. Le
1.139 avankest 1334:  Hégaret, L. Wood, G. Nicol, J. Robie, M. Champion, S. Byrne,
 1335:  editors. W3C, April 2004.</dd>
1.11 avankest 1336: 
1.37 avankest 1337:  <dt>[<dfn id="DOM3EV">DOM3Events</dfn>]</dt>
1.24 avankest 1338: 
1.92 avankest 1339:  <dd><cite><a href="http://www.w3.org/TR/DOM-Level-3-Events/">Document
1.139 avankest 1340:  Object Model (DOM) Level 3 Events Specification</a></cite> (work in
 1341:  progress), Björn Höhrmann, editor. W3C, April 2006.</dd>
1.11 avankest 1342: 
1.117 avankest 1343:  <dt>[<dfn id="ref-ecmascript">ECMAScript</dfn>]</dt>
1.24 avankest 1344: 
1.92 avankest 1345:  <dd><cite><a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMAScript
 1346:  Language Specification</a></cite>, Third Edition. ECMA, December 1999.</dd>
1.142 ! avankest 1347:  
 ! 1348:  <dt>[<dfn id="html5">HTML5</dfn>]</dt>
 ! 1349:  
 ! 1350:  <dd><cite><a href="http://www.whatwg.org/specs/web-apps/current-work/">HTML 5</a></cite>
 ! 1351:  (work in progress), Ian Hickson, editor. WHATWG, September 2007</dd>
1.14 avankest 1352: 
1.37 avankest 1353:  <dt>[<dfn id="ref-rfc2046">RFC2046</dfn>]</dt>
1.24 avankest 1354: 
1.19 avankest 1355:  <dd><cite><a href="http://ietf.org/rfc/rfc2046">Multipurpose Internet Mail
1.92 avankest 1356:  Extensions (MIME) Part Two: Media Types</a></cite>, N. Freed, N.
 1357:  Borenstein, editors. IETF, November 1996.</dd>
1.14 avankest 1358: 
1.37 avankest 1359:  <dt>[<dfn id="RFC2119">RFC2119</dfn>]</dt>
1.24 avankest 1360: 
1.117 avankest 1361:  <dd><cite><a href="http://ietf.org/rfc/rfc2119">Key words for use in RFCs to
 1362:  Indicate Requirement Levels</a></cite>, S. Bradner. IETF, March 1997.</dd>
1.12 avankest 1363: 
1.37 avankest 1364:  <dt>[<dfn id="RFC2616">RFC2616</dfn>]</dt>
1.24 avankest 1365: 
1.11 avankest 1366:  <dd><cite><a href="http://ietf.org/rfc/rfc2616">Hypertext Transfer Protocol
1.92 avankest 1367:  -- HTTP/1.1</a></cite>, R. Fielding, J. Gettys, J. Mogul, H. Frystyk, L.
 1368:  Masinter, P. Leach, T. Berners-Lee, editors. IETF, June 1999.</dd>
1.12 avankest 1369: 
1.37 avankest 1370:  <dt>[<dfn id="ref-rfc2617">RFC2617</dfn>]</dt>
1.24 avankest 1371: 
1.11 avankest 1372:  <dd><cite><a href="http://ietf.org/rfc/rfc2617">HTTP Authentication: Basic
1.92 avankest 1373:  and Digest Access Authentication</a></cite>, P. Hallam-Baker, J.
 1374:  Hostetler, S. Lawrence, P. Leach, A. Luotonen, L. Stewart, editors. IETF,
 1375:  June 1999.</dd>
1.12 avankest 1376: 
1.37 avankest 1377:  <dt>[<dfn id="ref-rfc2965">RFC2965</dfn>]</dt>
1.24 avankest 1378: 
1.19 avankest 1379:  <dd><cite><a href="http://ietf.org/rfc/rfc2965">HTTP State Management
1.92 avankest 1380:  Mechanism</a></cite>, D. Kristol, L. Montulli, editors. IETF, October
 1381:  2000.</dd>
1.19 avankest 1382: 
1.37 avankest 1383:  <dt>[<dfn id="ref-rfc3986">RFC3986</dfn>]</dt>
1.24 avankest 1384: 
1.11 avankest 1385:  <dd><cite><a href="http://ietf.org/rfc/rfc3986">Uniform Resource Identifier
1.92 avankest 1386:  (URI): Generic Syntax</a></cite>, T. Berners-Lee, R. Fielding, L. Masinter,
 1387:  editors. IETF, January 2005.</dd>
1.141 avankest 1388:  
 1389:  <dt>[<dfn id="ref-rfc3987">RFC3987</dfn>]</dt>
 1390:  
 1391:  <dd><cite><a href="http://ietf.org/rfc/rfc3987">Internationalized
 1392:  Resource Identifiers (IRIs)</a></cite>, M. Duerst, M. Suignard, editors.
 1393:  IETF, January 2005.</dd>
1.28 avankest 1394: 
1.92 avankest 1395:  <dt>[<dfn id="ref-window">Window</dfn>]</dt>
1.28 avankest 1396: 
1.92 avankest 1397:  <dd><cite><a href="http://www.w3.org/TR/Window/">Window Object
1.139 avankest 1398:  1.0</a></cite> (work in progress), I. Davis, M. Stachowiak, editors. W3C,
 1399:  April 2006.</dd>
1.41 avankest 1400: 
1.92 avankest 1401:  <dt>[<dfn id="ref-xml">XML</dfn>]</dt>
1.41 avankest 1402: 
1.92 avankest 1403:  <dd><cite><a href="http://www.w3.org/TR/xml/">Extensible Markup Language
 1404:  (XML) 1.0 (Fourth Edition)</a></cite>, T. Bray, J. Paoli, C.
1.117 avankest 1405:  Sperberg-McQueen, E. Maler, F. Yergeau, editors. W3C, September 2006.</dd>
1.41 avankest 1406: 
1.92 avankest 1407:  <dt>[<dfn id="ref-xmlns">XMLNS</dfn>]</dt>
1.41 avankest 1408: 
1.92 avankest 1409:  <dd><cite><a href="http://www.w3.org/TR/xml-names/">Namespaces in XML
1.117 avankest 1410:  (Second Edition)</a></cite>, T. Bray, D. Hollander, A. Layman, R. Tobin,
 1411:  editors. W3C, August 2006.</dd>
1.1 avankest 1412:  </dl>
1.11 avankest 1413: 
1.130 avankest 1414:  <h2 class="no-num" id="acknowledgments">Acknowledgments</h2>
1.11 avankest 1415: 
1.1 avankest 1416:  <p><em>This section is non-normative</em></p>
1.12 avankest 1417: 
1.7 avankest 1418:  <p>The editor would like to thank to the following people who have contributed
1.33 avankest 1419:  to this specification (ordered by first name):</p>
1.12 avankest 1420: 
1.1 avankest 1421:  <ul>
1.112 avankest 1422:  <li>Ahmed Kamel</li>
1.22 avankest 1423:  <li>Alex Hopmann</li>
1.7 avankest 1424:  <li>Alex Vincent</li>
1.15 avankest 1425:  <li>Alexey Proskuryakov</li>
1.136 avankest 1426:  <li>Asbjørn Ulsberg</li>
1.1 avankest 1427:  <li>Boris Zbarsky</li>
1.136 avankest 1428:  <li>Björn Höhrmann</li>
1.1 avankest 1429:  <li>Cameron McCormack</li>
 1430:  <li>Christophe Jolif</li>
 1431:  <li>Charles McCathieNevile</li>
1.54 avankest 1432:  <li>Dan Winship</li>
1.136 avankest 1433:  <li>David Håsäther</li>
1.1 avankest 1434:  <li>Dean Jackson</li>
1.126 avankest 1435:  <li>Denis Sureau</li>
1.1 avankest 1436:  <li>Doug Schepers</li>
 1437:  <li>Douglas Livingstone</li>
1.130 avankest 1438:  <li>Elliotte Harold</li>
1.112 avankest 1439:  <li>Eric Lawrence</li>
 1440:  <li>Gideon Cohn</li>
1.1 avankest 1441:  <li>Gorm Haug Eriksen</li>
 1442:  <li>Hallvord R. M. Steen</li>
1.136 avankest 1443:  <li>Håkon Wium Lie</li>
1.1 avankest 1444:  <li>Ian Davis</li>
 1445:  <li>Ian Hickson</li>
 1446:  <li>Ivan Herman</li>
1.134 avankest 1447:  <li>Jeff Walden</li>
1.136 avankest 1448:  <li>Jens Lindström</li>
1.1 avankest 1449:  <li>Jim Deegan</li>
 1450:  <li>Jim Ley</li>
1.112 avankest 1451:  <li>Joe Farro</li>
1.1 avankest 1452:  <li>Jonas Sicking</li>
 1453:  <li>Julian Reschke</li>
 1454:  <li>Karl Dubost</li>
 1455:  <li>Maciej Stachowiak</li>
1.7 avankest 1456:  <li>Magnus Kristiansen</li>
1.1 avankest 1457:  <li>Marc Hadley</li>
1.53 avankest 1458:  <li>Marcos Caceres</li>
1.87 avankest 1459:  <li>Mark Baker</li>
1.1 avankest 1460:  <li>Mark Nottingham</li>
1.92 avankest 1461:  <li>Mohamed Zergaoui</li>
1.1 avankest 1462:  <li>Pawel Glowacki</li>
 1463:  <li>Robin Berjon</li>
 1464:  <li>Ruud Steltenpool</li>
1.33 avankest 1465:  <li>Simon Pieters</li>
1.125 avankest 1466:  <li>Stewart Brodie</li>
1.112 avankest 1467:  <li>Sunava Dutta</li>
 1468:  <li>Zhenbin Xu</li>
1.1 avankest 1469:  </ul>
1.12 avankest 1470: 
1.1 avankest 1471:  <p>Special thanks to the Microsoft employees who first implemented the
1.22 avankest 1472:  <code>XMLHttpRequest</code> interface, which was first widely deployed by the
 1473:  Windows Internet Explorer browser.</p>
1.12 avankest 1474: 
1.54 avankest 1475:  <p>Special thanks also to the WHATWG for drafting an initial version of this
1.130 avankest 1476:  specification in their Web Applications 1.0 document (now renamed to
 1477:  HTML 5).</p>
1.12 avankest 1478: 
1.1 avankest 1479:  <p>Thanks also to all those who have helped to improve this specification by
1.22 avankest 1480:  sending suggestions and corrections. (Please, keep bugging us with your
 1481:  issues!)</p>
1.1 avankest 1482: </body>
 1483: </html>
Webmaster