腾讯位置获取位置模板
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>腾讯定位-jquery</title>
<meta content="width=device-width,height=device-height,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport">
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script><!-- 引用谷歌jQuery -->
</head>
<body></body>
<script type="text/javascript">
$(function(){
$.ajax({
type: "get",//接口规定,只能用get
async: true,//异步
url: "https://apis.map.qq.com/ws/location/v1/ip",//接口地址
data: {"key":"PTMBZ-GCQLW-SC2RG-R2FNI-HWPNQ-4PBQM","output":"jsonp"},//参数格式必须用到output传参为jsonp,否则会报跨域问题
dataType: "jsonp",//跨域,必须用到jsonp
success: function(result){
console.log(JSON.stringify(result));
document.write(JSON.stringify(result));
},
error: function (XMLHttpRequest,textStatus,errorThrown){
console.log(JSON.stringify(XMLHttpRequest));
document.write(JSON.stringify(XMLHttpRequest));
}
});
})
</script>
</html>