Advertisement
Guest User

before

a guest
Apr 24th, 2015
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.51 KB | None | 0 0
  1. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
  2.     <script>      
  3.         serviceLocation = "http://api.worldweatheronline.com/free/v2/weather.ashx";
  4.         key = "9a2ab8a1bf63124ed1a34091f203a";
  5.        
  6.         myQuery = {};
  7.         myQuery.format = "json";
  8.         myQuery.q = "London";
  9.         myQuery.num_of_days = "10";
  10.              
  11.  
  12.         req = serviceLocation + "?";
  13.         $.each(myQuery, function (k, v) {
  14.             req += k + '=' + v + '&';  
  15.         });  
  16.        
  17.         req += 'key' + '=' + key;
  18.        
  19.         $(document).ready(function (){
  20.        
  21.        
  22.          $.getJSON(req, function (res){
  23.        
  24.                
  25.                 var weatherIconUrl = res.data.current_condition[0].weatherIconUrl[0].value;              
  26.                 var observation_time = res.data.current_condition[0].observation_time;
  27.                 var temp_C = res.data.current_condition[0].temp_C;
  28.                 var cloudcover = res.data.current_condition[0].cloudcover;
  29.                            
  30.                 $('#infoSummary').html('<img src="' + weatherIconUrl + '" height="342" width="342">');            
  31.                 $('#infoDetails').html(
  32.                     "At the time <b>" + observation_time + "</b>" +
  33.                            " the " + myQuery.q + " temperature was <b>" + temp_C + " &deg;C </b>" +
  34.                            " with cloud cover of <b>" + cloudcover + "%</b>.");            
  35.             });
  36.         });      
  37.     </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement