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

86
Views
La referencia del objeto jQuery se resuelve en contenido html en la promesa de búsqueda

He escrito la función a continuación para cargar HTML en el elemento jQuery que se le pasó como referencia de objeto jQuery. Funciona bien dentro de la propia función. Sin embargo, la referencia del objeto se convierte en contenido HTML de la referencia. Lo necesito solo como referencia de objeto. Por favor, ayúdenme ya que no puedo encontrar ningún recurso o pregunta similar para resolver esto.

Aquí está la función:

 loadTargets(url, target) { console.log("target is ->" + target); // output: target is ->[object HTMLElement] $(target).html("loading..."); // resolves properly and HTML is updated as intended to "loading..." fetch(url) .then((response) =>{ return response.text(); }) .then((html) => { //passing target as additional arg doesn't help either jQuery(target).html(html); // doesn't work console.log("fresh target was: ", target) // Output: 'fresh target was: <header class="header"></header>' }) .catch((err) => {}); }

Llamada de función

 config.loaders.forEach(function(loader, index) { $(loader.target).each(function(index, loaderTarget){ // <--- this is jquery selector specifying to loop over each occurence of ta loadTargets(loader.file, loaderTarget); // <-- here this refers to that specific occurence }); });

He comprobado que no hay problema con la llamada de función.

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!