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

243
Views
Cómo solucionar este error: no se pueden leer las propiedades de undefined (leyendo 'longitud') en Javascript

Soy nuevo en Javascript. ¿Por qué este código me da el error: Cannot read properties of undefined (reading 'length') ? He intentado agregar el código datasrc antes pero no funciona. ¿Alguien más tiene una idea de cómo solucionarlo?

 //implement css in this files import './style.css'; //jquery already imported import $ from 'jquery'; // ajax to load // do table data binding here using data from variable resultArr var myArray = [] $.ajax({ method:'GET', url:'https://www.seetrustudio.com/data.php', success:function(response){ myArray = response.data buildTable(myArray) console.log(myArray) } }) function buildTable(data){ var table = document.getElementById('myTable') for (var i = 0; i < data.length; i++){ var row = `<tr> <td>${data[i].date}</td> <td>${data[i].weather}</td> <td>${data[i].temperature}</td> <td>${data[i].temp_unit}</td> </tr>` table.innerHTML += row } }`
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Hay un único lugar en su código donde se usa la length : data.length en for loop.

 for (var i = 0; i < data.length; i++){

Entonces, el intérprete dice I cannot read length of undefined , por lo tanto, data no están definidos, por lo tanto, myArray y response.data no están definidos y debe establecer un punto de interrupción en línea

 myArray = response.data

y ver qué hay en la respuesta y por qué no contiene los data clave.

about 4 years ago · Juan Pablo Isaza Report

0

Para mí, no he actualizado la clave API para mi aplicación. Cuando lo he hecho, el problema está resuelto.

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!