Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy JSON doesn't change when explicit assign value in Javascript
    text
    copied!<p>Why my JSON structure does not update when I explicit assign a new value?</p> <pre><code>items[0][i]['human_addressItem'] = address; </code></pre> <p>I am geo reversion latitude and Longitude to take the Human address, that part is working fine, but I can insert it into the JSON, why?</p> <p>This is the example running:</p> <p><a href="http://jsfiddle.net/KGbRh/" rel="nofollow">http://jsfiddle.net/KGbRh/</a></p> <p>CODE:</p> <p>HTML:</p> <pre><code>&lt;script src="http://code.jquery.com/jquery-2.0.2.min.js"&gt;&lt;/script&gt; &lt;script src="http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"&gt;&lt;/script&gt; &lt;script src="https://maps.googleapis.com/maps/api/js?v=3.exp&amp;sensor=false"&gt;&lt;/script&gt; &lt;div class="container-fluid"&gt; &lt;!-- Tables --&gt; &lt;section id="tables"&gt; &lt;table&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;[name]&lt;/th&gt; &lt;th&gt;[txtLat]&lt;/th&gt; &lt;th&gt;[txtLon]&lt;/th&gt; &lt;th&gt;[human_address]&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody id="items"&gt; &lt;script id="tmpItems" type="text/html"&gt; &lt;tr&gt; &lt;td&gt;&lt;input value="${name}" type="text" name="[name]"&gt;&lt;/td&gt; &lt;td&gt;&lt;input value="${Latitude}" type="text" name="[txtLat]"&gt;&lt;/td&gt; &lt;td&gt;&lt;input value="${Longitude}" type="text" name="[txtLon]"&gt;&lt;/td&gt; &lt;td&gt;&lt;input value="${human_addressItem}" type="text" name="[human_address]"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/script&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/section&gt; &lt;/div&gt; </code></pre> <p>JAVASCRIPT:</p> <pre><code> //GEOCORDER geocoder = new google.maps.Geocoder(); items = [ [{ "Longitude": -73.929489, "Latitude": 40.76079, "name": "Electronics" }, { "Longitude": -73.761727, "Latitude": 40.695817, "name": "02 Dodge (PICS)" }], { "active": 0 }]; for (var i = 0; i &lt; items[0].length; i++) { var address = ""; var lat = parseFloat(items[0][i]['Latitude']); var lng = parseFloat(items[0][i]['Longitude']); var latlng = new google.maps.LatLng(lat, lng); geocoder.geocode({ 'latLng': latlng }, function (results, status) { if (status == google.maps.GeocoderStatus.OK) { if (results[1]) { var address = results[1].formatted_address; //alert(address); console.log(address); } else { alert('No results found in: ' + items[0][i]['name']); } } else { alert('Geocoder failed due to: ' + status + " in: " + items[0][i]['name']); } }); items[0][i]['human_addressItem'] = address; } var o = items; $("#tmpItems").tmpl(items[0]).appendTo("#items"); </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