jquery 查询IP归属地
<script src="http://c.csdnimg.cn/public/common/libs/jquery/jquery-1.9.1.min.js" type="text/javascript"></script> <script type="text/javascript"> var response; $(function(){ $.get('http://jsonip.com/', callback); }); function callback(response){ // onsuccess callback happens ip = response.ip $.ajax({ url: "https://ali-ip.showapi.com/ip?ip=" + ip, beforeSend: function(xhr) { xhr.setRequestHeader("Authorization", "APPCODE 0dfa5cc63cf647ae8aca589f60e62e40"); }, type: 'GET', dataType: 'json', contentType: 'application/json', processData: false, data: '', success: function (data) { console.log(JSON.stringify(data)); }, error: function(){ alert("Cannot get data"); } }); } </script>