0

I need something similar to the code we have where we alert the coordinates but instead save those coordinates into a php file.

 var array = [];
          navigator.geolocation.getCurrentPosition(function(position) {
            var lat = position.coords.latitude;
            var lon = position.coords.longitude;
               array.push(lat, lon); 
                locationCode()         

});

function locationCode() {
   alert(array); 
}                // Try HTML5 geolocation.
        if (navigator.geolocation) {
          navigator.geolocation.getCurrentPosition(function(position) {
            var pos = {
              lat: position.coords.latitude,
            lng: position.coords.longitude

               };
5
  • "save those coordinates into a php file" is ambiguous. Do you mean you want to send that data to your PHP script so that it can save it somewhere? Commented Aug 24, 2016 at 0:30
  • 1
    There is a similar post: http://stackoverflow.com/questions/12813580/how-to-assign-php-array-values-to-javascript-array Commented Aug 24, 2016 at 0:31
  • convert to json array in javascript then use php json_decode function Commented Aug 24, 2016 at 0:35
  • @Sherif I want to send that data to a php script so I can save it somewhere on a server Commented Aug 24, 2016 at 0:36
  • Possible duplicate of Send array with Ajax to PHP script Commented Aug 24, 2016 at 0:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.