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

132
Views
¿Cómo llamar a una función de promesa que cargará contenido en una página dinámicamente?

Quiero cargar dinámicamente contenido en mi página usando promesa en javascript.

 <!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title>Main</title> <script type="text/javascript"> function func(url){ return new Promise(function(resolve, reject) { var request = new XMLHttpRequest(); request.open('GET', url); request.onload = function() { if (request.status == 200){ resolve(request.response); } else { reject(Error(request.statusText)); } }; request.onerror = function() { reject(Error("Network Error")) }; }); } $(document).ready(function() { func('hello.html'); }); </script> </head> <body> </body> </html>

Tengo el archivo hello.html en la misma carpeta y quiero cargarlo usando func(). ¿Es la forma correcta de hacerlo?

about 4 years ago · Santiago Trujillo
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!