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

196
Views
Los datos JSON no se obtienen

Estoy tratando de obtener datos json de una URL 'https://www.weatherinnovations.com/coop/weather.json' en un método tabular y usado $.getJSON pero los datos no se muestran en la página. la url contiene la extensión .json, quiero saber cómo puedo mostrarla en mi tabla desde la url

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <table class="table table-striped"> <tr class="bg-info"> <th>Date</th> <th>Max Temperature</th> <th>Min Temperature</th> <th>Average Temperature</th> <th>Precipitation</th> </tr> <tbody id="myTable"> </tbody> </table>

Formulario HTML

Guión JS

 var myArray = [] $.getJSON('https://www.weatherinnovations.com/coop/weather.json', function(data) { // JSON result in `data` variable myArray = response.data buildTable(myArray) console.log(myArray) }) buildTable(myArray) function buildTable(data){ var table = document.getElementById('myTable') for (var i = 0; i < data.length; i++){ var row = `<tr> <td>${data[i].DateTime}</td> <td>${data[i].Tmax}</td> <td>${data[i].Tmin}</td> <td>${data[i].Tavg}</td> <td>${data[i].Precip}</td> </tr>` table.innerHTML += row } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Dado que está recibiendo un error de política de CORS , lo que básicamente significa que los propietarios de la URL no quieren que use su URL de esta manera, solo hay dos formas de resolver esto:

  • Pídale a la gente de www.weatherinnovations.com que le permita usar su servicio agregando su sitio a su encabezado ACAO (generalmente poco probable, a menos que esté afiliado a ellos o tenga algún tipo de contrato), o

  • Dado que las restricciones de CORS solo se aplican al lado del cliente, puede acceder a la URL en su backend y entregar los contenidos a su frontend.

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!