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

209
Views
JavaScript Array no se puede actualizar en tiempo real

Escribo el siguiente código para intentar obtener una matriz del fondo usando XMlHttpRequest:

 var temp = new Array(); var httpRequest = new XMLHttpRequest(); httpRequest.open('POST', url, true); httpRequest.send(JSON.stringify(choose + "#" + input + "#")); httpRequest.onreadystatechange = function() { var message = httpRequest.responseText; var temps = message.split("#"); for (var i = 0; i < temps.length; i++) temp.push(temps[i]); } console.log(temp[0]); console.log(temp.length);

Pero la primera vez que lo ejecuto me devuelve length=0 y temp[0]=indefinido; Cuando lo ejecuto por segunda vez, me devuelve la longitud y la temperatura correctas [0], parece que la primera vez no se ejecutó en absoluto. ¿Cuál es el problema y cómo debo solucionarlo?

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!