--- title: XMLHttpRequestEventTarget.onload slug: Web/API/XMLHttpRequestEventTarget/onload translation_of: Web/API/XMLHttpRequestEventTarget/onload ---
El evento XMLHttpRequestEventTarget.onload
es la función que se llama cuando una transacción del {{domxref("XMLHttpRequest")}} es ejecutada correctamente.
XMLHttpRequest.onload = callback;
callback
is the function to be executed when the request completes successfully. It receives a {{domxref("ProgressEvent")}} object as its first argument. The value of this (i.e. the context) is the same {{domxref("XMLHttpRequest")}} this callback is related to.callback
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.var xmlhttp = new XMLHttpRequest(), method = 'GET', url = 'https://developer.mozilla.org/'; xmlhttp.open(method, url, true); xmlhttp.onload = function () { // Hacer algo con la información recivida ( found in xmlhttp.response ) }; xmlhttp.send();
Specification | Status | Comment |
---|---|---|
{{SpecName('XMLHttpRequest', '#handler-xhr-onload')}} | {{Spec2('XMLHttpRequest')}} | WHATWG living standard |
{{Compat("api.XMLHttpRequestEventTarget.onload")}}