I'm starting out with JSON, trying to implement a weather app using Open Weather Map's API. I'm trying to return the value for key "name" into <h2 id="city"></h2>
based on the user's coordinates, and I'm unsure as to why it's currently not returning anything. I understand something similar has been asked before, but I'm not sure how this applies in this case.
$(document).ready(function() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var lati = position.coords.latitude;
var longi = position.coords.longitude;
var address = "api.openweathermap.org/data/2.5/weather?lat=" + lati +"&lon=" + longi + "&APPID=*****";
$.getJSON(address, function(json) {
$("#city").html(json["name"]);
});
});
}
});