首页 > 编程开发 > JavaScript    日期:2020-02-20 / 来自互联网 / 浏览

搜狐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>

觉得上面的内容有用吗?快来点个赞吧!

点赞() 我要打赏

温馨提示 : 本站内容来自会员投稿以及互联网,所有源码及教程均为作者总结编辑,请大家在使用过程中提前做好备份,以免发生无法预知的错误,源码类教程请勿直接用于生产环境!

 可能感兴趣的文章