var api="https://fcc-weather-api.glitch.me/api/current?";
function getWeather(lat,lon){
var ustr = api + lat + "&" + lon;
$.ajax({
url: ustr, success:function(result){
$("#place").text(result.name+",");
$("#country").text(result.sys.country);
}
});
}
$( document ).ready(function(){
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
var lat = "lat=" + position.coords.latitude;
var lon = "lon=" + position.coords.longitude;
getWeather(lat, lon);
});
} else {
$("#place").html("Geolocation is not supported by this browser.");
}
})
无法从此JavaScript获取姓名和国家/地区,请提供帮助 我甚至试过j son功能,但dint显示任何结果