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

126
Views
Múltiples llamadas de funciones asíncronas secuenciales en <script> que deben esperarse, pero await no funciona

Entonces, estoy tratando de cargar varias instancias de una animación de lotería y los JSONS están en un cdn, el problema es que cargar estos JSONS es asíncrono, y tengo que hacer todo eso en etiquetas.

 <script> // the list of urls const urls = ["url", "url", "url", ...] // the function that gets each of the jsons, creates an array and returns it const getLottieJSONs = (urls) => { const lottieJSONs = []; for (let i = 0; i < urls.length; i++) { $.getJSON(urls[i], (data) => lottieJSONs.push(data)) } return lottieJSONs; } // creating the instances of the lotties with the retrieved data const createLottieInstances = (lottieContainers, lottieJSONs) => { const lottieInstances = []; for (let i = 0; i < lottieContainers.length; i++) { lottieInstances.push(bodymovin.loadAnimation({ container: lottieContainers[i], renderer: "svg", animationData: lottieJSONs[i], }) ); } return lottieInstances; } const lottieContainers = document.querySelectorAll(".ingredients-lottie-container"); // this does not have the data, before moving on to creating the instances and so it gives empty array to createLottieInstances const lottieJSONs = getLottieJSONs(urls); const lottieInstances = createLottieInstances(lottieContainers, lottieJSONs); // ... other code that uses the lottie instances ... </script>

Mi objetivo final es tener todas las instancias cargadas antes de llegar al código que las usa con los datos json reales.

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!