Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

129
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda