Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
- <script>
- serviceLocation = "http://api.worldweatheronline.com/free/v2/weather.ashx";
- key = "9a2ab8a1bf63124ed1a34091f203a";
- myQuery = {};
- myQuery.format = "json";
- myQuery.q = "London";
- myQuery.num_of_days = "10";
- req = serviceLocation + "?";
- $.each(myQuery, function (k, v) {
- req += k + '=' + v + '&';
- });
- req += 'key' + '=' + key;
- $(document).ready(function (){
- $.getJSON(req, function (res){
- var weatherIconUrl = res.data.current_condition[0].weatherIconUrl[0].value;
- var observation_time = res.data.current_condition[0].observation_time;
- var temp_C = res.data.current_condition[0].temp_C;
- var cloudcover = res.data.current_condition[0].cloudcover;
- $('#infoSummary').html('<img src="' + weatherIconUrl + '" height="342" width="342">');
- $('#infoDetails').html(
- "At the time <b>" + observation_time + "</b>" +
- " the " + myQuery.q + " temperature was <b>" + temp_C + " °C </b>" +
- " with cloud cover of <b>" + cloudcover + "%</b>.");
- });
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement