-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
34 lines (22 loc) · 915 Bytes
/
script.js
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
30
31
32
33
34
$(document).ready(function(){
$("#getWeatherForecast").click(function(){
var city = $("#city").val();
var key = '6507f13bae5e9a8e2a123874954c0f3e';
$.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 += '<h1><b>'+data.name+"</b><h1>" +"<h3>Temperature : "+ data.main.temp + '°C </h3>' /*+ val.main + ","*/+"<h3>Description : " + val.description+ '</h3>'
});
$("#showWeatherForecast").html(wf);
}
})
})
});