zoukankan      html  css  js  c++  java
  • 检测ip和地区

    获取当前位置所在省份城市和所用网络IP

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>检测ip和地区</title>
    </head>
    
    <body>
        <div class="box" style="text-align: center;">
            <h1>您当前所在ip和地区</h1>
            <p id="city"></p>
            <p id="ip"></p>
        </div>
    
        <script src="https://cdn.bootcss.com/jquery/1.9.1/jquery.min.js"></script>
        <script type="text/javascript">
            $(function(){
                //获取城市ajax
                $.ajax({
                url: 'http://api.map.baidu.com/location/ip?ak=ia6HfFL660Bvh43exmH9LrI6',  
                type: 'POST',  
                dataType: 'jsonp',
                success:function(data) {  
                    console.log(JSON.stringify(data));
                    $('#city').html(JSON.stringify(data.content.address_detail.province + "," + data.content.address_detail.city))
                }
                });
                //获取ip ajax
                $.ajax({
                    url: 'http://ip-api.com/json',
                    success: function(data){
                       console.log(JSON.stringify(data));
                       $('#ip').html(JSON.stringify(data.query))
                    },
                    type: 'GET',
                    dataType: 'JSON'
                });
            })
    
        </script>
    </body>
    </html>
  • 相关阅读:
    注解
    反射机制
    语法糖
    线程安全与锁优化
    java语法糖 之 泛型
    虚拟机字节码执行引擎
    虚拟机的类加载机制
    性能监控之可视化故障处理工具 Visualvm
    性能监控之可视化故障处理工具 JConsole
    Node of C++ Linker.
  • 原文地址:https://www.cnblogs.com/wrongcode/p/10584472.html
Copyright © 2011-2022 走看看