-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

4
  • the result is the lat and longitude of location from browser Commented Jul 20, 2012 at 15:23
  • Do you want to set a variable with this value? Commented Jul 20, 2012 at 15:24
  • Yes i do want to set a variable. So $location would be the coordinates Commented Jul 20, 2012 at 15:36
  • Edit the question here instead posting it again (with the missing infomration). Commented Jul 20, 2012 at 16:24

2 Answers 2

0

You need to make an ajax call to your server.

$.post(server, {lat: lat, lng:lng})
Sign up to request clarification or add additional context in comments.

Comments

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 :)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.