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

213
Views
obteniendo un error indefinido en JavaScript construyendo una tabla

Mi código funciona si solo lo envío a la pantalla. Pero cuando trato de poner los resultados en una tabla, la celda se llena con Indefinido. Creo que tiene que ver con un problema de alcance, pero parece que no puedo resolverlo. ¿Alguien puede ayudarme a comprender el alcance involucrado aquí y dónde me estoy equivocando?

Este es el que no funciona y da el error:

 var API_URL = 'https://xxxxxxxxxx.execute-api.us-east-1.amazonaws.com/prod/hunt'; $(document).ready(function() { $.ajax({ type: 'GET', url: API_URL, success: function(data) { data.Items.forEach(function(huntItem) { var table = document.getElementById("hunts"); let row = table.insertRow(1); let cell1 = row.insertCell(0); let cell2 = row.insertCell(1); let cell3 = row.insertCell(2); let cell4 = row.insertCell(3); let cell5 = row.insertCell(4); let cell6 = row.insertCell(5); cell1.innerHTML = huntItem.Name; cell2.innerHTML = huntItem.l1h; }) } }); });

Aquí está el HTML:

 <body> <h1>Hunting Results:</h1> <table id="hunts"> <tr> <th>Player</th> <th>Level 1</th> <th>Level 2</th> <th>Level 3</th> <th>Level 4</th> <th>Level 5</th> </tr> <div id="playerRow"> </div> </table>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Fue porque tenía un Nombre con N mayúscula. Debería nombrarse con n minúscula.

 cell1.innerHTML = huntItem.name; cell2.innerHTML = huntItem.l1h;

¡Esta versión funciona ahora! ¡Qué error de novato!

about 4 years ago · Juan Pablo Isaza Report
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!