I'm trying to put the variables lat and long inside the string url but it doesn't work. Here is my code:
$(document).ready(function() {
var long;
var lat;
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
lat = position.coords.latitude;
long = position.coords.longitude;
var api = "http://api.openweathermap.org/data/2.5/weather?lat='+lat+'&lon='+long+'&appid=c873adc18574701f4fb0abe01d927819";
$.getJSON(api, function(data) {
alert(data.name);
});
});
}
});
""to define the string and inside you are using'. Color coding show it is just one big string.