-1

可能重复:
将 js 变量传递给 php 变量

我有这个代码

  {
            var lat = position.coords.latitude;
            var lng = position.coords.longitude;
            alert("Current position: " + lat + " " + lng);
        }

我想将警报发布到这样的 php 变量

$location = above result

我怎样才能做到这一点?谢谢

4

2 回答 2

0

You need to make an ajax call to your server.

$.post(server, {lat: lat, lng:lng})
于 2012-07-20T15:24:06.093 回答
0

You can't pass directly from javascript to PHP.
If you want to do so, use AJAX, or just make your calculation in PHP first :)

于 2012-07-20T15:24:27.157 回答