jquery 获取客户端ip地址 和 地区位置

 
更多

搜狐IP地址查询接口(默认GBK):http://pv.sohu.com/cityjson

搜狐IP地址查询接口(可设置编码):http://pv.sohu.com/cityjson?ie=utf-8

使用搜狐接口demo:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../plugins/jQuery/jquery-1.12.4.min.js"></script>
    <script src="http://pv.sohu.com/cityjson"></script>
</head>
<body>
<p id="ip"></p>

<script type="text/javascript">
    $(function() {
        $('#ip').html(returnCitySN["cip"]);
    })

 //获取城市ajax
        $.ajax({
            url: 'http://api.map.baidu.com/location/ip?ak=ia6HfFL660Bvh43exmH9LrI6',
            type: 'POST',
            dataType: 'jsonp',
            success:function(data) {
                $('#city').html(data.content.address_detail.province + "," + data.content.address_detail.city)
            }
        });
    })
</script>
</body>
</html>
打赏

本文固定链接: https://www.cxy163.net/archives/3317 | 绝缘体

该日志由 绝缘体.. 于 2019年11月12日 发表在 未分类 分类下, 你可以发表评论,并在保留原文地址及作者的情况下引用到你的网站或博客。
原创文章转载请注明: jquery 获取客户端ip地址 和 地区位置 | 绝缘体
关键字: , , , ,

jquery 获取客户端ip地址 和 地区位置:等您坐沙发呢!

发表评论


快捷键:Ctrl+Enter