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
23 2812
Post your code so we can see where the problem might lie.
Thanks for your reply, The ajaxrequest is triggered by the following functions -
function getReportStatus(geturl)
-
{
-
var columnvals;
-
var filtervals;
-
url = geturl;
-
xmlObj = null;
-
xmlObj = GetXmlObj();
-
// This function is to choose the right xmlhttp object according to the browser
-
xmlObj.onreadystatechange=stateChanged;
-
xmlObj.open("GET", url , true);
-
xmlObj.send(null);
-
-
}
-
-
function stateChanged()
-
{
-
if (xmlObj.readyState==4 || xmlObj.readyState=="complete")
-
{
-
data = xmlObj.responseText;
-
var data_split = data.split("|");
-
-
document.getElementById("citystate").innerHTML= data_split[0];
-
document.getElementById("progress").innerHTML = data_split[1];
-
document.getElementById("function").innerHTML= data_split[2];
-
-
// All the ids above are div element ids which are inside individual <td> elements
-
-
}
-
/*
-
else if(xmlObj.readyState==1)
-
{
-
document.getElementById("citystate").innerHTML = "HEY";
-
document.getElementById("progress").innerHTML = "Loading";
-
document.getElementById("function").innerHTML = "Loading";
-
}
-
else if(xmlObj.readyState==3)
-
{
-
document.getElementById("citystate").innerHTML = "HEY";
-
document.getElementById("progress").innerHTML = "Loading";
-
document.getElementById("function").innerHTML = "Loading";
-
}
-
*/
-
}
-
Please let me know if you need any other piece of code as well.
Cheers
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.
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.
I've had a look, but I am unable to reproduce the problem.
Can you give me some exact steps to trigger the error.
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.
hey were you able to reproduce error now??
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.
Cool, thanks a lot. I would have a go at it and let you know. Appreciate the time you had spent on this.
Cheers
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.
I dont think FireBug is the issue in my case, as it shows 'undefined' even in other boxes with no firebug on.
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.
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.
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??
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.
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
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.
Did you have it as:
xmlObj.readyState == "4" (string) or
xmlObj.readyState == 4 (integer)?
sorry my bad, i have it as an integer not like the previous post.
xmlObj.readyState == 4
(integer).
I'm not sure which browsers require "complete", but you should also add in a check for status, i.e. - if (xmlObj.readyState == 4 || xmlObj.readyState == "complete") {
-
if (xmlObj.status == 200) { // OK
-
// now it's ready...
exactly now i have added status check and its working fine now.
Thanks for your help, much appreciated.
Cheers
You're welcome. Glad it's all working fine now. A simple solution in the end.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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:
...
|
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...
|
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
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
| |