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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -