Annotation of 2006/webapi/XMLHttpRequest/Overview.html, revision 1.104

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

Webmaster