Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

95
Vistas
El botón btn1_click no se está ejecutando

btn1_click no funciona. No hay errores ni advertencias en Visual Studio 2017. Tiene que haber algo simple que no estoy haciendo. Estoy seguro de que mi sitio api es correcto.

 <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>weatherjson</title> <style> body { position: fixed; top: 0px; bottom: 100%; height: 100%; left: 0px; right: 100%; width: 100%; background-color: green; } </style> </head> <body> <script type="text/javascript"> function btn1_click() { fetch('https://api.openweathermap.org/data/2.5/onecall?lat=40.79&lon=-81.347&exclude=minutely&appid=94d45728ae0f1341c6c5b0527162f90d').then(response => response.json()).then((obj) => { TextArea1.value = obj; }); } </script> <input id="Button1" type="button" value="get json" onclick="btn1_click()" /> <textarea id="TextArea1" rows="200" cols="200"></textarea> </body> </html>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

No hay nada de malo con su botón, pero creo que desea mostrar los datos en el área de texto, por lo que la forma de hacerlo debe escribir qué propiedades necesita mostrar, así es como debería verse.

 function btn1_click() { fetch( "https://api.openweathermap.org/data/2.5/onecall?lat=40.79&lon=-81.347&exclude=minutely&appid=94d45728ae0f1341c6c5b0527162f90d" ) .then((response) => response.json()) .then((obj) => { TextArea1.value = `${obj.lat} ${obj.lon} ${obj.timezone} ${obj.current.dt}`; }); }
 body { position: fixed; top: 0px; bottom: 100%; height: 100%; left: 0px; right: 100%; width: 100%; background-color: green; }
 <input id="Button1" type="button" value="get json" onclick="btn1_click()" /> <textarea id="TextArea1" rows="200" cols="200"></textarea>

Para ver qué propiedades están disponibles console.log(obj)

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda