-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforecast.js
More file actions
29 lines (22 loc) · 1.1 KB
/
forecast.js
File metadata and controls
29 lines (22 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
$(document).ready(function() {
// Get the 7 day forecast
$.ajax({
url: 'http://api.aerisapi.com/forecasts/' + zip + ' ?client_id=LI7gJnbLEdzpjWXZzBaMP&client_secret=4wgCjhk2sd0AC0YPbzsnp94X1HaY0EdSocIfwSEw',
dataType: "jsonp",
success: function(json) {
if (json.success) {
// Save the forecast as an array called fc
var fc = json.response;
// Show avgTemp for tomorrow
$('#tomorrow').html(fc[0].periods[0].avgTempF + '\u00B0');
// $('#tomorrow').append('<span class=tomorrow>' + 'tomorrow' + '</span>');
// Iterate through avgTemp for rest of week
for (i = 1; i < fc[0].periods.length; i++) {
$('#forecast').append('<div class=day' + '>' + '<span>' + fc[0].periods[i].avgTempF + '\u00B0' + '</span>' + '</div>');
}
} else {
alert('Unable to load forecast:' + json.error.description);
}
}
});
});