diff options
Diffstat (limited to 'files/it/web/api/xmlhttprequest/readystate/index.html')
| -rw-r--r-- | files/it/web/api/xmlhttprequest/readystate/index.html | 152 |
1 files changed, 152 insertions, 0 deletions
diff --git a/files/it/web/api/xmlhttprequest/readystate/index.html b/files/it/web/api/xmlhttprequest/readystate/index.html new file mode 100644 index 0000000000..a37fa1e1db --- /dev/null +++ b/files/it/web/api/xmlhttprequest/readystate/index.html @@ -0,0 +1,152 @@ +--- +title: XMLHttpRequest.readyState +slug: Web/API/XMLHttpRequest/readyState +translation_of: Web/API/XMLHttpRequest/readyState +--- +<p>{{APIRef('XMLHttpRequest')}}</p> + +<p>la proprietà <strong>XMLHttpRequest.readyState</strong> restituisce lo stato nel quale si trova il client di una richiesta XMLHttpRequest. Un client <abbr title="XMLHttpRequest">XHR</abbr> si può trovare in uno degli stati seguenti:</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>Il Client è stato creato, ma il metodo <code>open()</code> della XHR non è stato ancora invocato.</td> + </tr> + <tr> + <td><code>1</code></td> + <td><code>OPENED</code></td> + <td>Il metodo <code>open()</code> è stato invocato.</td> + </tr> + <tr> + <td><code>2</code></td> + <td><code>HEADERS_RECEIVED</code></td> + <td>Il metodo <code>send() </code>della XHR è stato invocato, e sono già disponibili lo status della risposta HTTP ed il suo header. </td> + </tr> + <tr> + <td><code>3</code></td> + <td><code>LOADING</code></td> + <td>Sta avvenendo il download dei dati; <code>responseText</code> contiene dati parziali.</td> + </tr> + <tr> + <td><code>4</code></td> + <td><code>DONE</code></td> + <td>L'operazione è stata completata.</td> + </tr> + </tbody> +</table> + +<dl> + <dt>UNSENT</dt> + <dd>Il Client è stato creato, ma il metodo <code>open()</code> della XHR non è stato ancora invocato.</dd> + <dt>OPENED</dt> + <dd>Il metodo <code>open() </code>della XHR è stato invocato. In questo stato è possibile settare l' header della richiesta HTTP utilizzando il metodo <a href="/en-US/docs/Web/API/XMLHttpRequest/setRequestHeader">setRequestHeader()</a>; può essere invocato il metodo <a href="/en-US/docs/Web/API/XMLHttpRequest/send">send()</a>, che inizia il fetch della richiesta.</dd> + <dt>HEADERS_RECEIVED</dt> + <dd>Il metodo send() è stato invocato e sono stati ricevuto gli headers della risposta; è possibile conoscere il codice della risposta HTTP ed i suoi metadati.</dd> + <dt>LOADING</dt> + <dd>Sta avvenendo il download del body della risposta HTTP; se il <code><a href="/en-US/docs/Web/API/XMLHttpRequest/responseType">responseType</a></code> è "text" o vuoto, <code><a href="/en-US/docs/Web/API/XMLHttpRequest/responseText">responseText</a> </code>conterrà un testo parziale.</dd> + <dt>DONE</dt> + <dd>L'operazione di fetch è terminata; Questo può significare sia che il trasferimento dei dati è stato un successo e questi sono completamente disponibili o che è fallito.</dd> +</dl> + +<div class="note"> +<p>The state names are different in Internet Explorer. Instead of <code>UNSENT</code>, <code>OPENED</code>,<code> HEADERS_RECEIVED</code>,<code> LOADING</code> and <code>DONE, the names READYSTATE_UNINITIALIZED</code> (0), <code>READYSTATE_LOADING</code> (1), <code>READYSTATE_LOADED</code> (2), <code>READYSTATE_INTERACTIVE</code> (3) and <code>READYSTATE_COMPLETE</code> (4) are used.</p> +</div> + +<h2 id="Example">Example</h2> + +<pre class="brush: js">var xhr = new XMLHttpRequest(); +console.log('UNSENT', xhr.readyState); // readyState sarà pari a 0 + +xhr.open('GET', '/api', true); +console.log('OPENED', xhr.readyState); // readyState sarà pari a 1 + +xhr.onprogress = function () { + console.log('LOADING', xhr.readyState); // readyState sarà pari a 3 +}; + +xhr.onload = function () { + console.log('DONE', xhr.readyState); // readyState sarà pari a 4 +}; + +xhr.send(null); +</pre> + +<h2 id="Specifications">Specifications</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + <tr> + <td>{{SpecName('XMLHttpRequest', '#states')}}</td> + <td>{{Spec2('XMLHttpRequest')}}</td> + <td>WHATWG living standard</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility">Browser compatibility</h2> + +<div>{{CompatibilityTable}}</div> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Chrome</th> + <th>Edge</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari (WebKit)</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{CompatChrome(1)}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatGeckoDesktop("1.0")}}<sup>[1]</sup></td> + <td>{{CompatIe(7)}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatSafari("1.2")}}</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Android</th> + <th>Chrome for Android</th> + <th>Edge</th> + <th>Firefox Mobile (Gecko)</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{CompatUnknown}}</td> + <td>1.0</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + </tr> + </tbody> +</table> +</div> |
