好的,这就是我正在使用的 javascript Link 。我遇到的问题是代码显示用户位置的地球而不是实际的城市。如果我改变
的值$(".currentLocation").html(city);
到
$(".currentLocation").html(data.name);
我得到的不是位置而是空白。
可能是因为您在 freegeoip 请求中调用 $get 而不是 $.get() 。
还要更改最后一行以使用 getLocation()
$(function() {
getLocation();
});