Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

228
Vistas
xhr timeout da un error de estado no válido en ie11

Estoy tratando de establecer el tiempo de espera en XMLHttpRequest pero muestra invalid state error , aquí está el código

 function get(url, options) { return new Promise((resolve, reject) => { const xhr = new XMLHttpRequest(); // headers if (options && options.headers) { for (let header in options.headers) { if (options.headers.hasOwnProperty(header)) { xhr.setRequestHeader(header, options.headers[header]); } } } xhr.open('GET', url); // FIXME: Why is IE11 failing on "xhr.timeout? // xhr.timeout = 10000; xhr.onload = function () { if (this.status >= 200 && this.status < 300) { try { const data = JSON.parse(xhr.responseText); resolve(data); } catch (ex) { reject({ status: this.status, statusText: xhr.statusText }); } } else { reject({ status: this.status, statusText: xhr.statusText }); } }; xhr.ontimeout = function () { reject({ status: this.status, statusText: xhr.statusText }); }; xhr.onerror = function () { reject({ status: this.status, statusText: xhr.statusText }); }; xhr.send(); }); } export default { get };

ingrese la descripción de la imagen aquí

Eché un vistazo a los siguientes enlaces link1 link2link3 y específicamente mantuve xhr.timeout entre xhr.open y xhr.send

Incluso probé esto

 xhr.onreadystatechange = function () { if(xhr.readyState == 1 ) { xhr.timeout = 5000; } };

pero sin suerte

about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Agregue xhr.timeout después del método xhr.open .

about 4 years ago · Santiago Trujillo Denunciar

0

Debe configurar xhr.timeout solo cuando llame a xhr.open() en modo asincrónico ; de lo contrario, MSIE generará una excepción INVALID_STATE_ERR .

Ejemplo: xhr.open("POST", url, true);

PD. Extrañamente, no veo este problema en FF y Chrome.

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda