here is my JS code and err info. the location name can be show. but the result can not show weather information. I do not know how to solve it. please help me.
$(document).ready(function () {
var lat;
var lon;
$('#location').text('loading . . .');
function getLocation() {
$.ajax({
url: 'https://ipapi.co/jsonp',
method: 'GET',
dataType: 'jsonp',
jsonpCallback: 'callback',
success: function (response) {
$('#location').text(response.city + ',' + response.country);
lat = response.latitude;
lon = response.longitude;
},
});
}
getLocation();
function getWeather(lat, lon) {
$.ajax({
url: 'https://fcc-weather-api.glitch.me/api/current?lat=' + lat + '&lon=' + lon,
method: 'GET',
dataType: 'JSON',
success: function (data) {
$('#location').text(data.weather[0].main);
},
});
}
getWeather(lat, lon);
});