-1

Possible Duplicate:
pass a js variable to a php variable

I have this code

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

I want to post the alert to a php variable like this

$location = above result

How can i accomplish this? Thank you

Community
  • 1
  • 1

2 Answers2

0

You need to make an ajax call to your server.

$.post(server, {lat: lat, lng:lng})
Harry
  • 52,711
  • 71
  • 177
  • 261
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 :)

PoulsQ
  • 1,936
  • 1
  • 15
  • 22