Setting the value of a variable in JavaScript
<p>As you can see in the following code I'm fetching data from the MySQL database, but I got stuck when I wanted to use fetched "location" to set the "position" of a marker on a google map.</p>

<pre><code>&lt;head&gt;
&lt;script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=xxxxxxxxxxxxxxxxxxxxx&amp;sensor=true"&gt;&lt;/script&gt;
&lt;script&gt;
  $.getJSON('http://www.wawhost.com/appProject/fetchmarker.php?callback=?', function(data) {
    for (var i = 0; i &lt; data.length; i++) {
      localStorage.loc = data[i].location;
    }
  });
&lt;/script&gt;
&lt;script&gt;
  function initialize() {
    var myLatlng = new google.maps.LatLng(-25.363882, 131.044922);
    var mapOptions = {
      zoom: 4,
      center: myLatlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    var map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);

    var marker = new google.maps.Marker({
      position: 'new google.maps.LatLng(' + localStorage.loc + ')',
      map: map,
      title: 'Hello World!'
    });
  }
&lt;/script&gt;
&lt;/head&gt;

&lt;body onload="initialize()"&gt;
&lt;div id="map_canvas"&gt;&lt;/div&gt;
&lt;/body&gt;
</code></pre>

<p>Thank you!</p>
