SHARE
TWEET

Untitled

a guest Apr 17th, 2018 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function(){
  2.    
  3.     $('#hoy').click(function(){
  4.         var ubicacion = $('#lugar').val();
  5.        
  6.         if (ubicacion != ''){
  7.            
  8.             $.ajax({
  9.                 url: "http://openweathermap.org/data/2.5/find?q=" + ubicacion + "&units=metric&appid=b6907d289e10d714a6e88b30761fae22",
  10.                 type:"GET",
  11.                 dataType: "json",
  12.                 success: function(data){
  13.                     console.log(data);
  14.                     //var infoTiempo = mostrarInfo(data);
  15.                     //$('#tiempo').html(infoTiempo);
  16.                 }
  17.             });
  18.            
  19.         }else{
  20.             $('#error').html('El campo ubicación no puede estar vacío');
  21.         }
  22.     });
  23. });
  24.  
  25. function mostrarInfo (data){
  26.     return "<h2>El tiempo en</h2><h3>" +data.name+ ", " + data.sys.country + "</h3>" +
  27.         "<h2>Tiempo: </h2><h3>" + data.weather[0].main + "</h3>" +
  28.         "<h2>Temperatura: </h2><h3>" + data.main.temp + "</h3>" +
  29.         "<h2>Humedad: </h2><h3>" + data.main.humidity + "</h3>";
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top