i have the following function for calculating distances.this function is the distance call back function.it goes throught all the alert statements but when it reaches the line in bold it throws an errorcannot read proprty "text of undefined".Is there anything i did wrong above such that my code cannot pass through this statement
Code:
function calculateDistanceCallback(response, status) {
if (status != google.maps.DistanceMatrixStatus.OK) {
alert('Error was: ' + status);
} else {
alert("in else");
var origins = response.originAddresses;
var destinations = response.destinationAddresses;
var outputDiv = document.getElementById('outputDiv');
outputDiv.innerHTML = '';
//deleteOverlays();
for (var i = 0; i < origins.length; i++) {
alert("in forloop");
var results = response.rows[i].elements;
alert("results" +results);
alert("in second for loop");
for (var j = 0; j < results.length; j++) {
alert("insyd second for loop");
alert("results" +results[j]);
[B]var a = results[j].distance.text.split(" ")[0];[/B]
alert("inbtwn for loop");
workingDistance = a;
///more code here
Comment