[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.31

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

Webmaster

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