Hello that such a friend turns out to be very stuck with this problem that happened to me in the work I want to save the coordinates latitude and longitude in php variable and then proceed to insert them in mysql but I can not make the javascript variable pass as is the php here I leave my code to analyze it if they could help me would be great GREETINGS FROM MEXICO
<html>
<head>
<script type='text/javascript'>
navigator.geolocation.getCurrentPosition(fn_ok, fn_error);
function fn_error(){
alert('Error');
}
function fn_ok(respuesta){
var lat = respuesta.coords.latitude;
var lon = respuesta.coords.longitude;
global=lat+' '+lon;
alert(global);
}
var global='hol';
</script>
</head>
<body>
<?php
$variablePHP =
"<script type='text/javascript'>;
var id=global;
document.writeln(id)
alert(id);
</script>";
echo $variablePHP;
?>
</body>
</html>
Here is the code but I can not get the latitude and longitus saved in the php variables if someone knows and could tell me how to solve the problem would help me a lot of thanks in advance to everyone.