Ajax Function for getting weather from FCC Weather API (https://fcc-weather-api.glitch.me) using longitude and latitude passed in as arguments.
function getWeather(latitude, longitude) {
$.ajax({
type: 'GET',
url: 'https://fcc-weather-api.glitch.me/api/current?lat='
+ latitude + '&lon=' + longitude,
async: false,
contentType: "application/x-www-form-urlencoded",
cache: false,
dataType: 'json',
success: function(data)
{
place = data.name + ", " + data.sys.country;
tempCel = data.main.temp;
condition = data.weather.main;
$("#location").html(place);
$("#weatherDegrees").html(tempCel + "C°");
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
console.log("Ajax fail");
}
});
}