473,406 Members | 2,619 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,406 software developers and data experts.

Exception with xmlHttp.status in mozilla/firefox

Hi all,

I wanted to know whether my page is connecting to server or not using
xmlHttp request.
For that , I am using one condition in onreadystatechange function as..
function xxx()
{
if(xmlhttp.readyState==4)
{

if(xmlhttp.status!=200)
{
error_handler();
}

----------
---------------------
}

}
This is working fine in IE when there is no connectivity with server( I
stoped the server)..

But it's giving exception in mozilla/firefox when I stopped the server
(only when I stop .),

at line 65 in my code, as
[Exception... "Component returned failure code: 0x80040111
(NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.status]" nsresult:
"0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame ::
http://localhost/teamkollab/chat2/chat-ajax.js :: responseDisplayChat
:: line 65" data: no]
line 65 is
-------------- if(xmlhttp.status != 200)

I could not access the xmlhttp.status variable .

Does it mean that xmlhttp object won't be returned with status code
when it can not connect to a page ??
If yes, what will it return to know the status ??
How could I solve this to not to get such exception ?

Please help me out ,
Thanks in advance

Dec 5 '06 #1
5 10750

Prasad wrote:
But it's giving exception in mozilla/firefox when I stopped the server
(only when I stop .),

at line 65 in my code, as
[Exception... "Component returned failure code: 0x80040111
(NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.status]" nsresult:
"0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame ::
http://localhost/teamkollab/chat2/chat-ajax.js :: responseDisplayChat
:: line 65" data: no]
line 65 is
-------------- if(xmlhttp.status != 200)

I could not access the xmlhttp.status variable .

Does it mean that xmlhttp object won't be returned with status code
when it can not connect to a page ??
If yes, what will it return to know the status ??
How could I solve this to not to get such exception ?
The Yahoo! UI connection manager
(http://developer.yahoo.com/yui/connection/) puts the xmlhttp.status
line in a try-catch block because of Firefox

try
{
if(o.conn.status !== undefined && o.conn.status != 0){
httpStatus = o.conn.status;
}
else{
httpStatus = 13030;
}
}
catch(e){
// 13030 is the custom code to indicate the condition -- in
Mozilla/FF --
// when the o object's status and statusText properties are
// unavailable, and a query attempt throws an exception.
httpStatus = 13030;
}

I haven't had a chance to study this more and their documentation
unfortunately doesn't specify what conditions calse the unavailability.

Flanagan's fifth edition simply states that reading the status when
readystate is less than 3 causes an error. Since XHR is not
standardized I imagine it was one of his observations in a particular
browser.

Peter

Dec 5 '06 #2

Peter Michaux wrote:
Prasad wrote:
But it's giving exception in mozilla/firefox when I stopped the server
(only when I stop .),

at line 65 in my code, as
[Exception... "Component returned failure code: 0x80040111
(NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.status]" nsresult:
"0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame ::
http://localhost/teamkollab/chat2/chat-ajax.js :: responseDisplayChat
:: line 65" data: no]
line 65 is
-------------- if(xmlhttp.status != 200)

I could not access the xmlhttp.status variable .

Does it mean that xmlhttp object won't be returned with status code
when it can not connect to a page ??
If yes, what will it return to know the status ??
How could I solve this to not to get such exception ?

The Yahoo! UI connection manager
(http://developer.yahoo.com/yui/connection/) puts the xmlhttp.status
line in a try-catch block because of Firefox

try
{
if(o.conn.status !== undefined && o.conn.status != 0){
httpStatus = o.conn.status;
}
else{
httpStatus = 13030;
}
}
catch(e){
// 13030 is the custom code to indicate the condition -- in
Mozilla/FF --
// when the o object's status and statusText properties are
// unavailable, and a query attempt throws an exception.
httpStatus = 13030;
}

I haven't had a chance to study this more and their documentation
unfortunately doesn't specify what conditions calse the unavailability.
Thanks,some how , I got rid of the problem ,but am still wondering why
it's giving exception when we are reading status variable ("only when
browser can't get any response from server ") . Doesn't it mean that
it's bug with firefox ??

Anyways , Thanks a lot ..

Flanagan's fifth edition simply states that reading the status when
readystate is less than 3 causes an error. Since XHR is not
standardized I imagine it was one of his observations in a particular
browser.

Peter
Dec 6 '06 #3

Peter Michaux wrote:
Prasad wrote:
But it's giving exception in mozilla/firefox when I stopped the server
(only when I stop .),

at line 65 in my code, as
[Exception... "Component returned failure code: 0x80040111
(NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.status]" nsresult:
"0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame ::
http://localhost/teamkollab/chat2/chat-ajax.js :: responseDisplayChat
:: line 65" data: no]
line 65 is
-------------- if(xmlhttp.status != 200)

I could not access the xmlhttp.status variable .

Does it mean that xmlhttp object won't be returned with status code
when it can not connect to a page ??
If yes, what will it return to know the status ??
How could I solve this to not to get such exception ?

The Yahoo! UI connection manager
(http://developer.yahoo.com/yui/connection/) puts the xmlhttp.status
line in a try-catch block because of Firefox

try
{
if(o.conn.status !== undefined && o.conn.status != 0){
httpStatus = o.conn.status;
}
else{
httpStatus = 13030;
}
}
catch(e){
// 13030 is the custom code to indicate the condition -- in
Mozilla/FF --
// when the o object's status and statusText properties are
// unavailable, and a query attempt throws an exception.
httpStatus = 13030;
}

I haven't had a chance to study this more and their documentation
unfortunately doesn't specify what conditions calse the unavailability.

Flanagan's fifth edition simply states that reading the status when
readystate is less than 3 causes an error. Since XHR is not
standardized I imagine it was one of his observations in a particular
browser.

Peter
Dec 6 '06 #4
VK

Prasad wrote:
Thanks,some how , I got rid of the problem ,but am still wondering why
it's giving exception when we are reading status variable ("only when
browser can't get any response from server ") . Doesn't it mean that
it's bug with firefox ??
Difficult to say. I mean it's already filed, but still seems discussed
either call it a "bug" or hell on it and so promote it into "feature"
:-)

See <https://bugzilla.mozilla.org/show_bug.cgi?id=238559>, Comment #2
explains your particular case.

Dec 6 '06 #5
VK

VK wrote:
See <https://bugzilla.mozilla.org/show_bug.cgi?id=238559>, Comment #2
explains your particular case.
Respectively on async calls you should always check .status inside
try{} block. On a network error IE will report the relevant status code
by MS tables (linked in the bug thread) while Gecko will simply raise
an exception you have to catch and interprete then as "Some network
error happened". In this aspect I see the YI script as error prone.

Dec 6 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Robert Cholewa | last post by:
Hi I'm using Microsoft.XMLHTTP object from within JavaScript HTA application (or WScript). Object is set to use asynchronous mode as following: --------- var oXMLRequest = new...
3
by: jw56578 | last post by:
anyone have a code example of using xmlhttp with mozilla, if i use the following code, the function is never called, but it does work in IE. xmlhttp.onreadystatechange = function() { if...
9
by: fochie | last post by:
Greetings, I'm having a problem when I try to GET a file from my server via xmlhttp when using Mozilla. With IE I can get any type of file fine, get/display headers fine, etc. With Mozilla,...
8
by: rithish | last post by:
I am on IE 6. I was trying out a simple xmlhttp function that send GET/POST requests. However, IE throws an 'unspecified error' when I call the 'setRequestHeader' method. The function that I am...
14
by: FMDeveloper | last post by:
Currently transitioning from a shared host to a dedicated server. The same code that works on the old server is not working on the dedicated server. It is a simple AJAX request like: <code>...
2
Plater
by: Plater | last post by:
I am using the XMLHttpRequest to send a request every 5ish seconds or so. Everything works fine until I take the server down that the object is trying to retrieve data from. Then the firefox...
4
by: sirjohnofthewest | last post by:
If I possessed the power to sway the mind of every user in the world to delete all forms of Internet Explorer I would die a happy man. Hi guys, I frequently visit this site to get answers to my...
3
by: Andrewh | last post by:
Hi, I am having a bit of a problem with using xmlhttp. The code of the javascript file is shown below used in Windows XP. var xmlhttp = null; function SetURLDiv(url) { if...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
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,...
0
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...

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.