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

167
Views
Cómo extraer algo de un objeto JSON y mostrarlo en el DOM

Me sigo sin definir en el DOM...

Estoy tratando de extraer la ciudad y el estado de esto y mostrarlo en el DOM.

 { "post code": "90210", "country": "United States", "country abbreviation": "US", "places": [ {"place name": "Beverly Hills", "longitude": "-118.4065", "state": "California", "state abbreviation": "CA", "latitude": "34.0901"} ] }
 var data = JSON.parse(ajax.responseText); //var str = ''; var boo = ''; //str = data[1]; boo += data.state; //document.getElementById('city').innerText = str; document.getElementById('state').innerHTML = boo; } else { // Status error! //document.getElementById('city').innerHTML = ajax.statusText; document.getElementById('state').innerHTML = ajax.statusText; }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Parece que el campo 'estado' está anidado en otro objeto que está anidado dentro de una matriz, por lo que la forma correcta de acceder sería

 data.places[0].state
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!