Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

151
Views
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 answers
Answer question

0

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

about 4 years ago · Santiago Trujillo Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!