So I been working on a class project using the public API from Open Weather Map (https://openweathermap.org/api).
I could get the temperature value but can't seem to display the icons. I read the documentation but don't understand it.
CODE
<input id="city">
<button id="getWeatherForcast">GET WEATHER</button>
<div class="ShowWeatherForcast"></div>
<script type="text/javascript">
$(document).ready(function() {
$("#getWeatherForcast").click(function() {
var city = $("#city").val();
var key = '4de3768c62b67fe359758977a3efc069';
$.ajax({
url: 'http://api.openweathermap.org/data/2.5/weather',
dataType: 'json',
type: 'GET',
data: {
q: city,
appid: key,
units: 'metric'
},
success: function(data) {
var wf = '';
$.each(data.weather, function(index, val) {
wf += '<p><b>' + data.name + "</b><img src=" + val.icon + ".png></p>" + data.main.temp + '°C ' +
' | ' + val.main + ", " + val.description
});
$(".ShowWeatherForcast").html(wf);
}
})
});
});
</script>