大家好,又见面了,我是你们的朋友全栈君。
<!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>
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/163161.html原文链接:https://javaforall.net