我想使用地理定位 API 获取用户位置,它正在获取位置但没有调用回调方法。
function success(postion) {
console.log("Success Function");
console.log(postion);
alert(postion);
}
function error(message) {
console.log("Error Function");
console.log(message);
alert(message);
}
$(document).ready(function () {
try
{
console.log("Getting location");
navigator.geolocation.getCurrentPosition(success);
console.log("Location Got Successfully");
}
catch(e)
{
console.log(e.message);
}
});
这是控制台日志
Getting location Test.aspx (line 53)
Location Got Successfully Test.aspx (line 55)