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

192
Views
¿Por qué jQuery devuelve una matriz indefinida?

Estoy tratando de leer un archivo json del servidor usando jQuery para usar esos datos para crear funciones específicas en el sitio. El archivo json es una matriz de objetos.

 function populate() { var dataArr = []; $.getJSON('http://localhost/teamproject/item_data.json', function(data) { for (let i = 0; i < data.length; i++) { dataArr.push([data[i].name, data[i].price, data[i].postage, data[i].itemID, data[i].start, data[i].end]); } return dataArr; }); }

Y entonces

 function filterTime(change) { var selectedValue = change.value; let data = populate(); console.log(data); }

La console.log(data); imprime undefined . ¿Cómo puedo devolver esta matriz correctamente en la función populate() ?

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!