--- title: XMLHttpRequestEventTarget.onload slug: Web/API/XMLHttpRequestEventTarget/onload translation_of: Web/API/XMLHttpRequestEventTarget/onload --- <div>{{APIRef("XMLHttpRequest")}}</div> <p>El evento <strong><code>XMLHttpRequestEventTarget.onload</code> </strong>es la función que se llama cuando una transacción del {{domxref("XMLHttpRequest")}} es ejecutada correctamente.</p> <h2 id="Syntax" name="Syntax">Sintaxis</h2> <pre class="syntaxbox"><em>XMLHttpRequest</em>.onload = <em>callback</em>;</pre> <h3 id="Valores"> Valores</h3> <ul> <li><code><em>callback</em></code> is the function to be executed when the request completes successfully. It receives a {{domxref("ProgressEvent")}} object as its first argument. The value of <em>this</em> (i.e. the context) is the same {{domxref("XMLHttpRequest")}} this callback is related to.</li> <li><code><em>callback</em></code> es la función a ser ejecutada cuando la petición se complete. Ésta recive un objeto {{domxref("ProgressEvent")}} como su primer argumento. El valor de esto (ej: el contexto) es el mismo {{domxref("XMLHttpRequest")}} al que el callback está relacionado.</li> </ul> <h2 id="Example" name="Example">Ejemplo</h2> <pre class="brush: js">var xmlhttp = new XMLHttpRequest(), method = 'GET', url = 'https://developer.mozilla.org/'; xmlhttp.open(<em>method</em>, <em>url</em>, true); xmlhttp.onload = function () { // Hacer algo con la información recivida ( found in xmlhttp.response ) }; xmlhttp.send(); </pre> <h2 id="Especificaciones">Especificaciones</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', '#handler-xhr-onload')}}</td> <td>{{Spec2('XMLHttpRequest')}}</td> <td>WHATWG living standard</td> </tr> </tbody> </table> <h2 id="Browser_compatibility">Browser compatibility</h2> <p>{{Compat("api.XMLHttpRequestEventTarget.onload")}}</p>