How to read JSON response from Google web services in Javascript? <p>I am trying to find the distance between two locations. For that I used Google web services. I got a JSON response from that web service, but I am unable to get the distance from that JSON response in a javascript function.</p> <p>See my code below:</p> <pre><code>function myjourneysubdetails(){ var fp = jQuery('#fp').val(); var tp = jQuery('#tp').val(); var city = jQuery('#city').val(); alert(fp); $.ajax({ type : 'GET', url : 'http://maps.googleapis.com/maps/api/distancematrix/json?origins=Silk board&amp;destinations=marathahalli&amp;language=en-US&amp;sensor=false', async: false, success : function(data) { alert("Success"); var locObject = eval('(' + JSON.stringify(data) + ')'); alert("locObject: "+locObject); alert("Destination: "+locObject.destination_addresses); var origins = data.origin_addresses; var destinations = data.destination_addresses; alert('destinations'+destinations); for (var i = 0; i &lt; origins.length; i++) { var results = data.rows[i].elements; for (var j = 0; j &lt; results.length; j++) { var element = results[j]; var distance = element.distance.text; var duration = element.duration.text; var from = origins[i]; var to = destinations[j]; alert('distance'+distance); } } }, error : function(xhr, type) { alert('Internal Error Occoured! '+xhr+' : '+type); } }); } </code></pre> <p>Thanks in advance.</p>