通过js实现查询手机号码归属地
<!DOCTYPE html>
<html>
<head>
<meta charset="gbk">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>js查询手机号码归属地</title>
<script src="http://cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript">
(function(){
$.ajax({
url:"http://apis.baidu.com/showapi_open_bus/mobile/find",
type:"get",
beforeSend: function(request) {
request.setRequestHeader("apikey", "d2c83ec********a385c8b");//此处填写apikey,可以在apistore注册获取
},
data:{num:'187****5962'},
datatype:"json",
success:function(res){
console.info(res.showapi_res_body.city);//结果包含很多信息,此处取出城市名做个示例
}
});
})(jQuery)
</script>
</head>
<body>
</body>
</html>
网友评论