javascript - how to store latitude and longitude in database? -
i want latitude , longitude store in database getting google map.
function successfunction(position) { var lat = position.coords.latitude; var longi = position.coords.longitude; $.ajax({ type: 'post', data: { latitude : lat, longitude : longi }, url: "ajax.php"//.... //... passing on server }); }
but not happening and
ajax.php page this
<?php //include("config.php"); $con=mysqli_connect("localhost","root","","test1"); $latitude = mysql_real_escape_string($_get['lat']); $longitude = mysql_real_escape_string($_get['lon']); $query = mysql_query($con,"insert current_location (lat, lon, datetime) values ('$latitude', '$longitude', now())") or die(mysql_error()); mysqli_close($con); ?>
can explain me please.
this:
data: { latitude : lat, longitude : longi },
becomes
$_post['latitude']; $_post['longitude'];
the js syntax is
data: { key1: value1, key2:value2, ...}
yours backwards.
Comments
Post a Comment