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

118
Vistas
Continously call xmlhttprequest when onload completes

I am trying to show a slideshow on a screen running a old version of Samsungs Hospitality Browser. the browser does not support fetch or promises so i have to use xmlhttprequest, the problem is i want to call the xmlhttprequest again when the slideshow is done. Currently it is called recursively, but that means the callstack never is cleared, so it's not really a sustainable fix.

xmlhttprequest:

function getData(url) {
  var req = new XMLHttpRequest();
  req.overrideMimeType("application/json");
  req.open('GET', url, true);
  req.onload = function () {
    var jsonResponse = JSON.parse(req.responseText);
    generateSlides(jsonResponse);
  };
  req.send();
}

the function showing the images and calling the xmlhttprequest recursively

function showPosters(slides, slideIndex) {
  console.log(slideIndex);
  setPoster(slides[slideIndex]);
  slideIndex++;
  if (slideIndex == slides.length + 1) {
    getData("http://localhost:5000/Posters");
  } else {
    setTimeout(showPosters, 4000, slides, slideIndex);
  }
}

Is there any way to wait until the callback is complete, when await and promises isn't supported?

about 4 years ago · Juan Pablo Isaza
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