sorry this one is more organized
var lat, lon, weather;
if ('geolocation' in navigator) {
navigator.geolocation.getCurrentPosition(location, error);
} else {
alert("Geolocation not supported");
}
function error() {
alert("Sorry you are in outer space");
}
function location(position) {
lat = position.coords.latitude;
lon = position.coords.longitude;
weather = "api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + lon + "&units=metric&APPID=";
$.ajax({
url: weather,
dataType: 'jsonp',
success: function(data) {
var temp = data.main.temp;
$("#temp").html(temp);
}
});
}
I didnt want to share my api
&callback=?
to the end of your url
:star2: 1347 | @dhcodes |http://www.freecodecamp.com/dhcodes