为什么我无法从json响应中获得位置?

Why am I unable to get the location from this jsonp response?

本文关键字:位置 响应 json 为什么      更新时间:2023-09-26

我是jQuery的新手,基于JSFiddle,我编写了一个脚本来定位自己。下面是我的脚本:

       $(document).ready(function(){
            $.get("http://ipinfo.io", function (response) {
                $("#ip").html("" + response.ip);
                $("#hostname").html("" + response.hostname);
                $("#city").html("" + response.city);
                $("#region").html("" + response.region);
                $("#country").html("" + response.country);
                $("location").html("" + response.loc);
                $("#organisation").html("" + response.org);
            },"jsonp");
        });  

一切都很顺利,只是我找不到位置。但是,在JSFiddle中,可以恢复位置。

如何检索位置坐标:)

你好,你错过了$("#location") #它已经在JSFiddle中更新了

$.get("http://ipinfo.io", function (response) {
    $("#ip").html("IP: " + response.ip);
    $("#address").html("Location: " + response.city + ", " + response.region);
    $("#location").html("Location Lat Long:"+response.loc);
    $("#details").html(JSON.stringify(response, null, 4));
}, "jsonp");