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

121
Views
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
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!