473,394 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Firefox - 'undefined' error

I have a page with table layout which has an AJAX request sent on body onLoad event, during this time the table cells show static text like "Loading". The table cells are later updated with the AJAX response. So when I try to move out of the page once the AJAX request is sent by clicking on a link for exmple, the "Loading" changes to "undefined". I read that innerHTML is not supported by firefox for table cells so i started using div inside the table cell yet no result. However IE and Opera seems to work fine. could anyone please tell me where am going wrong ?? Thanks a ton
May 7 '08 #1
23 2812
acoder
16,027 Expert Mod 8TB
Post your code so we can see where the problem might lie.
May 7 '08 #2
Thanks for your reply, The ajaxrequest is triggered by the following functions

Expand|Select|Wrap|Line Numbers
  1. function getReportStatus(geturl)
  2. {
  3.    var columnvals;
  4.    var filtervals;
  5.    url = geturl;
  6.    xmlObj = null;
  7.    xmlObj = GetXmlObj(); 
  8. // This function is to choose the right xmlhttp object according to the browser
  9.    xmlObj.onreadystatechange=stateChanged;
  10.    xmlObj.open("GET", url , true);
  11.    xmlObj.send(null);
  12.  
  13. }
  14.  
  15. function stateChanged()
  16.  {
  17.      if (xmlObj.readyState==4 || xmlObj.readyState=="complete")
  18.      {
  19.          data = xmlObj.responseText;
  20.          var data_split = data.split("|");
  21.  
  22.           document.getElementById("citystate").innerHTML= data_split[0];
  23.           document.getElementById("progress").innerHTML = data_split[1];
  24.           document.getElementById("function").innerHTML= data_split[2];
  25.  
  26.          // All the ids above are div element ids which are inside individual <td> elements
  27.  
  28.      }
  29. /*
  30.      else if(xmlObj.readyState==1)
  31.      {
  32.         document.getElementById("citystate").innerHTML = "HEY";
  33.         document.getElementById("progress").innerHTML = "Loading";
  34.         document.getElementById("function").innerHTML = "Loading";
  35.      }
  36.      else if(xmlObj.readyState==3)
  37.      {
  38.         document.getElementById("citystate").innerHTML = "HEY";
  39.         document.getElementById("progress").innerHTML = "Loading";
  40.         document.getElementById("function").innerHTML = "Loading";
  41.      }
  42. */
  43.   }
  44.  
Please let me know if you need any other piece of code as well.


Cheers
May 7 '08 #3
acoder
16,027 Expert Mod 8TB
I'll also need to see the relevant HTML code. If the code is too much and you have a test site link, post that instead.
May 7 '08 #4
Is it possible i can email you my test site?? I dont want it to be public

Thanks again

I'll also need to see the relevant HTML code. If the code is too much and you have a test site link, post that instead.
May 7 '08 #5
acoder
16,027 Expert Mod 8TB
PM me instead.
May 7 '08 #6
acoder
16,027 Expert Mod 8TB
I've had a look, but I am unable to reproduce the problem.

Can you give me some exact steps to trigger the error.
May 7 '08 #7
once you click the button 'Create Report' you will be inside the report center. Once you are are inside the report center, click on any link just to navigate away from the page. When you click on the link the the table cells which were saying 'Loading' would disappear and you will see 'undefined' appearing in those cells for a very brief time before you end up in the next page.Please let me know if you were able to reproduce it this time. Thanks for your efforts again.
May 7 '08 #8
hey were you able to reproduce error now??
May 8 '08 #9
acoder
16,027 Expert Mod 8TB
Yes, it seems it's only triggered if you leave the page.

I'm not sure what might be triggering it, but perhaps you need to abort the request onunload.
May 8 '08 #10
Cool, thanks a lot. I would have a go at it and let you know. Appreciate the time you had spent on this.

Cheers
May 8 '08 #11
Plater
7,872 Expert 4TB
I have noticed on FF a lot when using the FireBug addon that it shows various javascript functions as "undefined" when you attempt to navigate away from a page, that might have pending javascript code running.
May 8 '08 #12
I dont think FireBug is the issue in my case, as it shows 'undefined' even in other boxes with no firebug on.
May 8 '08 #13
acoder
16,027 Expert Mod 8TB
Yes, it seems it's only triggered if you leave the page.

I'm not sure what might be triggering it, but perhaps you need to abort the request onunload.
The XMLHttpRequest object has an abort() method which you can use or set the variable to null. Just make sure that the request hasn't already finished. If it has, then there's nothing to worry about anyway.
May 9 '08 #14
Plater
7,872 Expert 4TB
Well I get the undefined error for other functions that have no relation to the xmlhttprequest stuff. They shouldn't even be being accessed, but firebug still likes to throw errors for it.
May 9 '08 #15
I tried nulling the xmlhttp object, but still remains the same. I dont really understand how the error gets triggered. Not all the table cells show undefined, only two columns does that. The other column which is also updated with the AJAX response goes blank instead of saying undefined. There are no differences between these columns though. I cant think of a reason why firefox would do it... any suggestions??
May 9 '08 #16
Plater
7,872 Expert 4TB
If you try to call a method/function on an object that doesn't support it, you frequently are returned "undefined"
Like trying to use TOSTRING() vs toString() and such.
May 9 '08 #17
Problem sorted,

" xmlObj.readyState == "4" || xmlObj.readyState=="complete" "

This is the line that had the problem. The readyState receives only a numeric response and no string. So this was breaking the script here when i compare readyState to "Complete" and was returning an empty responseText all the time. So when i tried to split responseText and add it to the div elements the first element went null and the others were saying undefined.

Any explanation on why this would break in firefox alone would be appreciated.


Thanks for all your help guys

Cheers
May 12 '08 #18
Plater
7,872 Expert 4TB
IE "doesn't care"?
Also, I notice that in IE, the ready state will be set to a winsock error code number when such events arrive (like host not found), whereas FF throws a javascript exception. So be sure to use try/catch statements.
May 12 '08 #19
acoder
16,027 Expert Mod 8TB
Did you have it as:
xmlObj.readyState == "4" (string) or
xmlObj.readyState == 4 (integer)?
May 12 '08 #20
sorry my bad, i have it as an integer not like the previous post.

xmlObj.readyState == 4
(integer).
May 13 '08 #21
acoder
16,027 Expert Mod 8TB
I'm not sure which browsers require "complete", but you should also add in a check for status, i.e.
Expand|Select|Wrap|Line Numbers
  1. if (xmlObj.readyState == 4 || xmlObj.readyState == "complete") {
  2.     if (xmlObj.status == 200) { // OK
  3.         // now it's ready...
May 13 '08 #22
exactly now i have added status check and its working fine now.

Thanks for your help, much appreciated.

Cheers
May 13 '08 #23
acoder
16,027 Expert Mod 8TB
You're welcome. Glad it's all working fine now. A simple solution in the end.
May 13 '08 #24

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

Similar topics

2
by: Johnny | last post by:
Searched on google for any info relating to this before posting here but found none. I set up a web service using nusoap on apache php 4.3.8 on windows with error_reporting = E_ALL and had that...
4
by: Stuart Perryman | last post by:
Hi, I have the following code which works just fine in IE6 but not in Firefox. It is an extract of several table rows each with an individual form. It is generated by php. <form...
15
by: Dan | last post by:
Hi. I've got the following line of code which works fine in IE ... line_1_numbers = document.getElementsByTagName ('table').rows (0).cells (0).innerText; But it Firefox, it barks saying: ...
5
by: Martin Chen | last post by:
I have a frame set (as per MS FrontPage 2000). It has a contents and a main frame. The contents frame has a menu bar written with with javascript (in the context of a table). In IE6.1 everything...
5
by: Mark D Smith | last post by:
Hi anyone know what the java error is on this page? http://www.s-nta.org.uk/index.html Mark
1
by: dasayu | last post by:
Hi, I have a custom object called gridWidget. I am consistantly getting an error in FireFox when I click on an href, which calls a function defined on the object. The generated link looks similar...
7
by: Coder | last post by:
Hi I have the following code in java script, it is not giving proper output in FIREFOX but running fine in IE... can anybody help me out to make this run in FIREFOX . <script...
3
by: jon | last post by:
Hello, I've had long standing code that runs in IE, that I'm testing with firefox unsuccessfully now. The problem seems to be that images that I dynamically create don't fire their onload event...
9
by: johnd126 | last post by:
I have a cgi program which outputs a fairly hefty amount of html/javascript for doing a complex slide show sorta thing in a variety of areas in the browser. I accomplish this by creating a series...
7
by: rwaller | last post by:
Works fine in IE, but not in Firefox? Code below, thank you in advance.... http://www.cnusd.k12.ca.us/roosevelt%2Dhs/Leaving_Site/leavingERHSpavelgcy.html <SCRIPT LANGUAGE=vbscript> function...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...

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.