Reputation: 1074
don't know where the problem is but nothing was displayed in the div selected .
$(document).ready(function(){
var lat, lng, data;
// get the current location
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
lat = position.coords.latitude;
lng = position.coords.longitude;
});
}else {
alert('Geo Location feature is not supported in this browser.');
}
//get the data from the openWeatherMap API
function getData(){
$.getJSON('api.openweathermap.org/data/2.5/weather?lat='+lat+'&lon='+lng+'', function(json){
data = json;
});
}
$('button').on('click', function(){
getData();
$(this).remove();
$('.container').removeClass('hidden');
$('#location').appendTo(data.name);
$('#Weather-condition').appendTo(data.weather.main);
$('#wind-speed').appendTo(data.wind);
});
});
Upvotes: 1
Views: 150
Reputation: 63
you can find this problem from two side
Upvotes: 1