I am making one project where I have to get longitude and latitude of user, to mark the place where the he is and so on. The problem is to save longitude and latitude in php variable, which at the end will be saved in MySQL database. So, does anyone know is that possible to achieve.
1 Answer
See example here http://html5demos.com/geo. Than change it:
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(success, error);
} else {
error('not supported');
}
function successFunction(position) {
var lat = position.coords.latitude;
var longi = position.coords.longitude;
$.ajax({
type: 'POST',
data: { latitude : lat, longitude : longi },
url: //....
//... passing on server
});
}
1 Comment
Chris Dormani
This is not going to continuously store the lat lang
ajaxfrom js to php and save them to mysql or whatever. look for how to making an ajax call..