Note that there are some explanatory texts on larger screens.

plurals
  1. POaccessing php variables in javascript
    primarykey
    data
    text
    <p>what i am trying to achieve is basically mark the location of all the users logged into my chat which is another thing. so i though i'd use geolocation api (http://code.google.com/apis/gears/api_geolocation.html) and store the generated location in a session variable. but its not working. here is the code-` </p> <pre><code>&lt;?php $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; ?&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('data was passed!'); }); }, 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;` </code></pre> <p>and the problem is. that the variable seslatlng is set to (0,0) always which is not what i want. i am new to PHP and i only have rough idea how server side scripting works. can somebody please fix this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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