469,358 Members | 1,639 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,358 developers. It's quick & easy.

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 10568

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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Robert Cholewa | last post: by
3 posts views Thread by jw56578 | last post: by
3 posts views Thread by Andrewh | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.