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

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

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

Webmaster

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