搜狐IP地址查询接口(默认GBK):http://pv.sohu.com/cityjson
搜狐IP地址查询接口(可设置编码):http://pv.sohu.com/cityjson?ie=utf-8
获取城市位置:http://api.map.baidu.com/location/ip?ak=ia6HfFL660Bvh43exmH9LrI6
$(function () {
$.ajax({
url: 'http://api.map.baidu.com/location/ip?ak=ia6HfFL660Bvh43exmH9LrI6',
type: 'POST',
dataType: 'jsonp',
success: function (res) {
console.log(res)
console.log(res.address)
console.log(res.content.address)
console.log(res.content.address_detail.adcode)
console.log(res.content.address_detail.city)
console.log(res.content.address_detail.city_code)
console.log(res.content.address_detail.district)
console.log(res.content.address_detail.province)
console.log(res.content.address_detail.street)
console.log(res.content.address_detail.street_number)
}
});
});
<script src="jquery.min.js"></script>
<div>
<input id="province" type="text">
</div>
<button id="submit">提交</button>
<script src="position.js"></script>
<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
$("span").html(returnCitySN["cip"]);
<span></span>
原文地址:
https://www.couragesteak.com/article/408
更多前端文章:
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。