473,503 Members | 1,818 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cannot read property "text"of undefined

5 New Member
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


Expand|Select|Wrap|Line Numbers
  1. function calculateDistanceCallback(response, status) {
  2.  
  3.                  if (status != google.maps.DistanceMatrixStatus.OK) {
  4.                    alert('Error was: ' + status);
  5.                  } else {
  6.                      alert("in else");
  7.                    var origins = response.originAddresses;
  8.                    var destinations = response.destinationAddresses; 
  9.                    var outputDiv = document.getElementById('outputDiv');
  10.  
  11.                    outputDiv.innerHTML = '';
  12.                    //deleteOverlays();
  13.                    for (var i = 0; i < origins.length; i++) {
  14.                        alert("in forloop");
  15.                      var results = response.rows[i].elements;
  16.                      alert("results" +results);
  17.                      alert("in second for loop");
  18.                      for (var j = 0; j < results.length; j++) {
  19.                          alert("insyd second for loop");
  20.  
  21.                          alert("results" +results[j]);
  22.                      var a = results[j].distance.text.split(" ")[0];
  23.  
  24.                    alert("inbtwn for loop");
  25.                      workingDistance = a;
  26.  
  27. ///more code here
Feb 27 '14 #1
7 3712
Dormilich
8,658 Recognized Expert Moderator Expert
that’s because results[j] is not an object (or does not contain a distance property, but the alert() above pretty much rules that out).
Feb 27 '14 #2
belz
5 New Member
My code goes up to the alert which says second for loop.so what should i do to make the code work.can you write the code for me containing the change
Feb 27 '14 #3
Dormilich
8,658 Recognized Expert Moderator Expert
there’s another alert() beneath that one, what does it show?
Feb 27 '14 #4
belz
5 New Member
hi.am using alerts as debug statements.lyk i said my code goz up to the alert wch says results +resulte[j].it doesnt proceed to go and print out the other alerts.meaning the prroblem is were ere is e distance.text code.bcz dats e only code inbtwn e 2 alert statrnents
Mar 3 '14 #5
Dormilich
8,658 Recognized Expert Moderator Expert
lyk i said my code goz up to the alert wch says results +resulte[j]
and if that alert doesn’t show "[object Object]", then post #2 applies—you’re working with the wrong array.
Mar 3 '14 #6
belz
5 New Member
it does produce object Object.then doesnt proceed
Mar 3 '14 #7
Dormilich
8,658 Recognized Expert Moderator Expert
then it doesn’t have—as I already said—a distance property.
Mar 3 '14 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2691
by: bb | last post by:
Hello In my Session_OnStart in Global.asa, I am setting some cookies. One of them, I set as follows: dim UserID UserID = Request.ServerVariables("LOGON_USER") Response.Cookies("User")("ID")...
5
13406
by: Axel Dachtler | last post by:
Hi, I have a listener problem. The listener cannot read SERVICE_NAME in TNS-Descriptor. The service-name I specified in Oracle Net Manager for this database is testdb as well. ...
2
2577
by: Jill | last post by:
Hi I am using ms acces 2002 to read an xml file. I am using the DOM object in ms access - version xml 4 with service pack 2. here is the start of the code below. But I am having trouble reading...
0
1522
by: Christopher Attard | last post by:
Hi, I'm using the PerformanceCounter .NET class to obtain the "% Processor Time" for processes that are running on a remote host. These processes are obtained using the...
8
1901
by: Fendi Baba | last post by:
I created an ASP.net page which opens excel. The data opens up correctly in MS office Excel 2007 but when we use a mahcine with MS Office 2003 we encountered a message, "Cannot read output file" Is...
15
2977
by: waltbrad | last post by:
Hello. I'm studying the book "C++ Primer Plus" by Stephan Prata. In chapter 6 he gives an exercise that reads from a file. The list is thus: 4 Sam Stone 2000 Freida Flass 100500 Tammy...
4
4054
by: pedro | last post by:
application cannot read the app.config file i have a config file for the executable i try to read it but it throws an exception when building the setup for the project vs2005 do not add the...
8
3404
by: gkhangelani | last post by:
Hi How would I fix an error below: server.log file :
1
4211
by: ANDRE BERTONHA | last post by:
When I use streamReader.ReadLine() this gives me the following subject error ( " cannot read closed textreader " ) I am reading an entire folder with .txt files containing sql query...
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7330
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7460
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.