From: pete on
Hi everybody --

I'm only starting with AJAX. I have a button on the html page that
overloads a table with new, up-to-date markup and content. Three out
of four times under FF 3.6.8, this works great. But it often yields
the infamous (to many) and mysterious (to me) error report:

uncaught exception: [Exception... "Component returned failure code:
0x80004005 (NS_ERROR_FAILURE) [nsIXMLHttpRequest.send]" nsresult:
"0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: http://www.the
domain.com/cgi-bin/cgicode :: submit :: line 1183" data: no]

Google yields tons of questions (going back years) about this error,
but I haven't found too many helpful answers. One common, unhelpful
suggestion is to get rid of the X FIrefox plugin.

So: can anyone tell me what this message means; which readystate the
thing comes from; and what I can do to correct whatever error the
message is talking about? I do notice the "data: no" in the msg, and I
sure can reissue the request. But is that the correct -- and
foolproof; and only -- thing to do?

Thanks, all. I appreciate any help. This thing is making me crazy.

-- pete
From: David Mark on
On Aug 2, 5:47 am, pete <pete...(a)yahoo.com> wrote:
> Hi everybody --
>
> I'm only starting with AJAX. I have a button on the html page that
> overloads a table with new, up-to-date markup and content. Three out
> of four times under FF 3.6.8, this works great.

Exactly three out of four times?

> But it often yields
> the infamous (to many) and mysterious (to me) error report:

One out of four is not often. :)

>
> uncaught exception: [Exception... "Component returned failure code:
> 0x80004005 (NS_ERROR_FAILURE) [nsIXMLHttpRequest.send]" nsresult:
> "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame ::http://www.the
> domain.com/cgi-bin/cgicode :: submit :: line 1183" data: no]

For something so famous, I can't recall seeing it.

>
> Google yields tons of questions (going back years) about this error,

Searching for answers to JS questions on Google is rarely fruitful.
There are just too many confused people out there.

> but I haven't found too many helpful answers.

What helpful answers have you found?

> One common, unhelpful
> suggestion is to get rid of the X FIrefox plugin.

Sounds like a typical stab in the dark.

>
> So: can anyone tell me what this message means; which readystate the
> thing comes from;

It appears to happen on calling the send method.

> and what I can do to correct whatever error the
> message is talking about?

Hard to say without seeing your code.

> I do notice the "data: no" in the msg, and I
> sure can reissue the request. But is that the correct -- and
> foolproof; and only -- thing to do?

Do what? Ignore the error and carry on?

>
> Thanks, all. I appreciate any help. This thing is making me crazy.
>

It's not doing me any good either. :(
From: Thomas 'PointedEars' Lahn on
pete wrote:

> I'm only starting with AJAX. I have a button on the html page that
> overloads a table with new, up-to-date markup and content. Three out
> of four times under FF 3.6.8, this works great. But it often yields
> the infamous (to many) and mysterious (to me) error report:
>
> uncaught exception: [Exception... "Component returned failure code:
> 0x80004005 (NS_ERROR_FAILURE) [nsIXMLHttpRequest.send]" nsresult:
> "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: http://www.the
> domain.com/cgi-bin/cgicode :: submit :: line 1183" data: no]
>
> Google yields tons of questions (going back years) about this error,
> but I haven't found too many helpful answers. One common, unhelpful
> suggestion is to get rid of the X FIrefox plugin.

It is possible, but rather unlikely that a plugin (or, what you probably
mean instead, an extension) is the culprit in your case. (I have never
heard of an "X plugin" before, BTW.) You should have posted the relevant
parts of your code and the *exact* error message (with the exact domain
name) for further analysis, see also <http://jibbering.com/faq/#posting>.
Without that, only educated guesses (or flippant, yet somewhat justified,
responses) are left.

Chances are that everything works as designed, that you are using the same
XHR instance for two or more concurrent HTTP requests. In that case there
would be a race condition: The send() method can only be called on an XHR
instance if that instance has been initialized (open() has been called on
it) but is not already sending a request or handling a response (i.e., the
value of the `readyState' property is either 1 or 4). There would be no
problem if the response for the first request was processed completely
before you make the second request; otherwise the exception above would be
thrown, and since you would not catch it, logged to the Error Console (and
the script would terminate afterwards). The latter can happen in your
application if any of the following applies: You click the button in short
succession, your Internet connection is slower than usual, your Web server
is slower to respond than usual.

You would either need to use two different XHR instances then, or you would
need to wait with the second request until the first response has been fully
received (readyState == 4, in the latter case to be checked against in the
function referred to by the value of the `onreadystatechange' property of
the instance). (Therefore, a good XHR library should IMHO recognize the
condition of the XHR instance and create a new instance only when necessary,
in order to save heap memory, if the request parameters and the response
handler are the same as before.)

You can check the Mozilla source code (written in C++, not that hard to
understand for a JS/ES developer) to be sure about the cause of the
exception. Searching the corresponding code branch (see: Help menu, About…
item, "rv:…") on <http://mxr.mozilla.org/> (or even on Google!) for the
identifier "nsIXMLHttpRequest" (see the error message) would most certainly
prove helpful then. Incidentally, there is a posting from me from March
2006 (CE) that explains this very problem. Google lists it right on top for
at least `NS_ERROR_FAILURE nsIXMLHttpRequest' (you see, NS_ERROR_FAILURE is
a general error code in Mozilla; *context* is key.)


HTH

PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300dec7(a)news.demon.co.uk>