XMLHttpRequest.hx 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * Copyright (C)2005-2013 Haxe Foundation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20. * DEALINGS IN THE SOFTWARE.
  21. */
  22. // This file is generated, do not edit!
  23. package js.html;
  24. /** <p><code>XMLHttpRequest</code> is a <a class="internal" title="En/JavaScript" rel="internal" href="https://developer.mozilla.org/en/JavaScript">JavaScript</a> object that was designed by Microsoft and adopted by Mozilla, Apple, and Google. It's now being <a class="external" title="http://www.w3.org/TR/XMLHttpRequest/" rel="external" href="http://www.w3.org/TR/XMLHttpRequest/" target="_blank">standardized in the W3C</a>. It provides an easy way to retrieve data at a URL. Despite its name, <code>XMLHttpRequest</code> can be used to retrieve any type of data, not just XML, and it supports protocols other than <a title="en/HTTP" rel="internal" href="https://developer.mozilla.org/en/HTTP">HTTP</a> (including <code>file</code> and <code>ftp</code>).</p>
  25. <p>To create an instance of <code>XMLHttpRequest</code>, simply do this:</p>
  26. <pre>var req = new XMLHttpRequest();
  27. </pre>
  28. <p>For details about how to use <code>XMLHttpRequest</code>, see <a class="internal" title="En/Using XMLHttpRequest" rel="internal" href="https://developer.mozilla.org/en/DOM/XMLHttpRequest/Using_XMLHttpRequest">Using XMLHttpRequest</a>.</p><br><br>
  29. Documentation for this class was provided by <a href="https://developer.mozilla.org/en/XMLHttpRequest">MDN</a>. */
  30. @:native("XMLHttpRequest")
  31. extern class XMLHttpRequest extends EventTarget
  32. {
  33. /** The operation is complete. */
  34. static inline var DONE : Int = 4;
  35. /** <code>send()</code> has been called, and headers and status are available. */
  36. static inline var HEADERS_RECEIVED : Int = 2;
  37. /** Downloading; <code>responseText</code> holds partial data. */
  38. static inline var LOADING : Int = 3;
  39. /** <code>send()</code>has not been called yet. */
  40. static inline var OPENED : Int = 1;
  41. /** <code>open()</code>has not been called yet. */
  42. static inline var UNSENT : Int = 0;
  43. var onabort : EventListener;
  44. var onerror : EventListener;
  45. var onload : EventListener;
  46. var onloadend : EventListener;
  47. var onloadstart : EventListener;
  48. var onprogress : EventListener;
  49. var onreadystatechange : EventListener;
  50. /** <p>The state of the request:</p> <table class="standard-table"> <tbody> <tr> <td class="header">Value</td> <td class="header">State</td> <td class="header">Description</td> </tr> <tr> <td><code>0</code></td> <td><code>UNSENT</code></td> <td><code>open()</code>has not been called yet.</td> </tr> <tr> <td><code>1</code></td> <td><code>OPENED</code></td> <td><code>send()</code>has not been called yet.</td> </tr> <tr> <td><code>2</code></td> <td><code>HEADERS_RECEIVED</code></td> <td><code>send()</code> has been called, and headers and status are available.</td> </tr> <tr> <td><code>3</code></td> <td><code>LOADING</code></td> <td>Downloading; <code>responseText</code> holds partial data.</td> </tr> <tr> <td><code>4</code></td> <td><code>DONE</code></td> <td>The operation is complete.</td> </tr> </tbody> </table> */
  51. var readyState(default,null) : Int;
  52. /** The response entity body according to <code><a href="#responseType">responseType</a></code>, as an <a title="en/JavaScript typed arrays/ArrayBuffer" rel="internal" href="https://developer.mozilla.org/en/JavaScript_typed_arrays/ArrayBuffer"><code>ArrayBuffer</code></a>, <a title="en/DOM/Blob" rel="internal" href="https://developer.mozilla.org/en/DOM/Blob"><code>Blob</code></a>, <code><a rel="custom" href="https://developer.mozilla.org/en/DOM/Document">Document</a></code>
  53. , JavaScript object (for "moz-json"), or string. This is <code>NULL</code>&nbsp;if the request is not complete or was not successful. Getter throws DOMException. */
  54. var response(default,null) : Dynamic;
  55. /** The response to the request as text, or <code>null</code> if the request was unsuccessful or has not yet been sent. <strong>Read-only.</strong> Getter throws DOMException. */
  56. var responseText(default,null) : String;
  57. /** <p>Can be set to change the response type. This tells the server what format you want the response to be in.</p> <table class="standard-table"> <tbody> <tr> <td class="header">Value</td> <td class="header">Data type of <code>response</code> property</td> </tr> <tr> <td><em>empty string</em></td> <td>String (this is the default)</td> </tr> <tr> <td>"arraybuffer"</td> <td><a title="en/JavaScript typed arrays/ArrayBuffer" rel="internal" href="https://developer.mozilla.org/en/JavaScript_typed_arrays/ArrayBuffer"><code>ArrayBuffer</code></a></td> </tr> <tr> <td>"blob"</td> <td><code><a rel="custom" href="https://developer.mozilla.org/en/DOM/Blob">Blob</a></code>
  58. </td> </tr> <tr> <td>"document"</td> <td><code><a rel="custom" href="https://developer.mozilla.org/en/DOM/Document">Document</a></code>
  59. </td> </tr> <tr> <td>"text"</td> <td>String</td> </tr> <tr> <td>"moz-json"</td> <td>JavaScript object, parsed from a JSON string returned by the server
  60. <span title="(Firefox 9.0 / Thunderbird 9.0 / SeaMonkey 2.6)
  61. ">Requires Gecko 9.0</span>
  62. </td> </tr> </tbody> </table> Setter throws DOMException. */
  63. var responseType : String;
  64. /** <p>The response to the request as a DOM <code><a class="internal" title="En/DOM/Document" rel="internal" href="https://developer.mozilla.org/en/DOM/document">Document</a></code> object, or <code>null</code> if the request was unsuccessful, has not yet been sent, or cannot be parsed as XML. The response is parsed as if it were a <code>text/xml</code> stream. <strong>Read-only.</strong></p> <div class="note"><strong>Note:</strong> If the server doesn't apply the <code>text/xml</code> Content-Type header, you can use <code>overrideMimeType()</code>to force <code>XMLHttpRequest</code> to parse it as XML anyway.</div> Getter throws DOMException. */
  65. var responseXML(default,null) : Document;
  66. /** The status of the response to the request. This is the HTTP result code (for example, <code>status</code> is 200 for a successful request). <strong>Read-only.</strong> Getter throws DOMException. */
  67. var status(default,null) : Int;
  68. /** The response string returned by the HTTP server. Unlike <code>status</code>, this includes the entire text of the response message ("<code>200 OK</code>", for example). <strong>Read-only.</strong> Getter throws DOMException. */
  69. var statusText(default,null) : String;
  70. /** The upload process can be tracked by adding an event listener to <code>upload</code>.
  71. <span>New in <a rel="custom" href="https://developer.mozilla.org/en/Firefox_3.5_for_developers">Firefox 3.5</a></span> */
  72. var upload(default,null) : XMLHttpRequestUpload;
  73. /** <p>Indicates whether or not cross-site Access-Control requests should be made using credentials such as cookies or authorization headers.
  74. <span>New in <a rel="custom" href="https://developer.mozilla.org/en/Firefox_3.5_for_developers">Firefox 3.5</a></span>
  75. </p> <div class="note"><strong>Note:</strong> This never affects same-site requests.</div> <p>The default is <code>false</code>.</p> Setter throws DOMException. */
  76. var withCredentials : Bool;
  77. function new() : Void;
  78. function abort() : Void;
  79. function getAllResponseHeaders() : String;
  80. function getResponseHeader( header : String ) : String;
  81. function open( method : String, url : String, ?async : Bool, ?user : String, ?password : String ) : Void;
  82. function overrideMimeType( override_ : String ) : Void;
  83. /** <p>Sends the request. If the request is asynchronous (which is the default), this method returns as soon as the request is sent. If the request is synchronous, this method doesn't return until the response has arrived.</p>
  84. <div class="note"><strong>Note:</strong> Any event listeners you wish to set must be set before calling <code>send()</code>.</div>
  85. <div id="section_11"><span id="Parameters_3"></span><h6 class="editable">Parameters</h6>
  86. <dl> <dt><code>body</code></dt> <dd>This may be an <code>nsIDocument</code>, <code>nsIInputStream</code>, or a string (an <code>nsISupportsString</code> if called from native code) that is used to populate the body of a POST request. Starting with Gecko 1.9.2, you may also specify an DOM<code><a rel="custom" href="https://developer.mozilla.org/en/DOM/File">File</a></code>
  87. , and starting with Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)
  88. you may also specify a <a title="en/XMLHttpRequest/FormData" rel="internal" href="https://developer.mozilla.org/en/DOM/XMLHttpRequest/FormData"><code>FormData</code></a> object.</dd>
  89. </dl>
  90. </div> Throws DOMException. */
  91. @:overload( function() :Void {} )
  92. @:overload( function( data : ArrayBuffer ) :Void {} )
  93. @:overload( function( data : ArrayBufferView ) :Void {} )
  94. @:overload( function( data : Blob ) :Void {} )
  95. @:overload( function( data : Document ) :Void {} )
  96. @:overload( function( data : String ) :Void {} )
  97. function send( data : DOMFormData ) : Void;
  98. function setRequestHeader( header : String, value : String ) : Void;
  99. }