Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>when you are using jquery's ajax get function, what you wanna do is call a php function that <strong>only</strong> returns the locations. this is how is should look:</p> <pre><code>&lt;?php if ( $_GET['test'] ) { $my_lat= $_GET['test']; // get data $my_long= $_GET['fname']; $my_name = "vivek"; $lat1=28.635308; $long1=77.22496; //$latitude = $_GET['latitude']; //$longitude = $_GET['longitude'];// get data echo $my_lat.''.$my_long; } else { ?&gt; &lt;script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key='' &amp;sensor=true"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function(){ if(navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { var lat = position.coords.latitude; var longi= position.coords.longitude; var url = 'bam.php'; //post to the server! $.get(url, { test: lat,fname: longi },function(data){ alert('My location is: ' + data); }); }, function() { //now is when the marking should be done. handleNoGeolocation(true); }); } }); &lt;/script&gt; &lt;script type="text/javascript"&gt; function initialize() { var myLatlng = new google.maps.LatLng(28.635308,77.22496); var myOptions = { zoom: 4, center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP } var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); var thelat = '&lt;?php echo $my_lat;?&gt;'; var thelong = '&lt;?php echo $my_long;?&gt;'; var seslatlng = new google.maps.LatLng(thelat,thelong); alert(seslatlng); var marker = new google.maps.Marker({ position: seslatlng, map: map, animation: google.maps.Animation.DROP, title:"Hello world!" }); } &lt;/script&gt; &lt;?php } ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload