【发布时间】:2018-07-27 09:24:03
【问题描述】:
我在 index.php 中的代码是
<script type="text/javascript">
window.onload=function(){
function callback(position) {
latitude = position.coords.latitude;
longitude = position.coords.longitude;
alert(latitude);
alert(longitude);
}
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(callback);
}
}
</script>
我需要在index.php中显示经纬度的值
<?php echo $lat; ?>,
<?php echo $long; ?> how can i get value here?
【问题讨论】:
-
异步 HTTP 请求 (AJAX)。也许是 Websocket。无法通过客户端(如您所料)。
-
不能直接将javascript变量赋值给php变量,使用cookie来实现
标签: javascript php wordpress