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

178
Views
No se puede devolver un valor de una función cuando se usa xhttp en javascript

Aquí el valor devuelto no está definido en la variable b. Porque estoy tratando de devolver un valor de función anidado, supongo. ¿Cómo puedo devolver el valor de x desde la función de accionamiento aquí?

 function drive() { let xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function(){ if(this.readyState == 4 && this.status == 200){ var x = JSON.parse(this.response); console.log(x); return x; // return 1; } } xhttp.open("GET","https://api.openweathermap.org/data/2.5/find?q=Chennai&appid=0d0a354784e8166b7b9fee6a3a29bcc2&units=metric"); xhttp.send(); } document.getElementById("clickme").addEventListener("click", function () { let b = drive(); console.log(b); })
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!