Problem with XmlHttpRequest (0x80040111 / nsIXMLHttpRequest.status) on several configurations

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Greg

    Problem with XmlHttpRequest (0x80040111 / nsIXMLHttpRequest.status) on several configurations

    Hi,

    I've designed a bookmark in Ajax / PHP that I will put soon on
    sourceforge.net .
    But I've got an very tricky bug.
    I try it on some computers with Internet Explorer/Windows, Firefox
    1.07/Linux, Firefox 1.5/Linux, Firefox 1.5/Windows and Firefox 1.5/Mac,
    Safari/Mac.
    It works perfectly on a lot of configurations but, on some PC with
    Firefox 1.5/Windows (not all), the Javascript code with XmlHttpRequest
    don't work at all and I've got this message when I refresh the webpage
    :
    --------------------------------------------------------------------------------------
    "Erreur : [Exception... "Component returned failure code: 0x80040111
    (NS_ERROR_NOT_A VAILABLE) [nsIXMLHttpReque st.status]" nsresult:
    "0x80040111 (NS_ERROR_NOT_A VAILABLE)" location: "JS frame ::
    http://someWebServer/BookmarkAjax/js/requestor.js :: anonymous :: line
    52" data: no]
    Fichier source : http://someWebServer/BookmarkAjax/js/requestor.js
    Ligne : 52"
    --------------------------------------------------------------------------------------

    Here is the source :
    --------------------------------------------------------------------------------------
    "function getReadyStateHa ndler(req, responseXmlHand ler) {
    // Return an anonymous function that listens to the XMLHttpRequest
    instance
    return function () {
    // If the request's status is "complete"
    if (req.readyState == 4) {

    // Check that a successful server response was received[color=blue][color=green][color=darkred]
    >>> L.52 >>>> if (req.status == 200) {[/color][/color][/color]

    // Pass the XML payload of the response to the
    // handler function
    var debug = document.getEle mentById("debug ");
    debug.innerHTML += "<br/>" + req.status + " " + req.statusText;

    responseXmlHand ler(req.respons eXML);

    } else { ..."
    --------------------------------------------------------------------------------------
    This piece of source code comes from an IBM's article :


    It's very strange because it is working on some configurations and not
    at all on others, all based on Firefox 1.5/Windows....
    There's a lot of message on the web about this kind of error but I
    don't find this exactly case !
    I would be glad if somebody could help me.
    (I can give you an access on the web application by email if you wan't
    to reproduce this bug)
    Thanks - Greg

  • Greg

    #2
    Re: Problem with XmlHttpRequest (0x80040111 / nsIXMLHttpReque st.status) on several configurations

    I've still got the problem.
    I can't find why.

    Comment

    • Ian Collins

      #3
      Re: Problem with XmlHttpRequest (0x80040111 / nsIXMLHttpReque st.status)on several configurations

      Greg wrote:[color=blue]
      > I've still got the problem.
      > I can't find why.
      >[/color]
      Have you tried if (req.status && req.status == 200)?

      --
      Ian Collins.

      Comment

      • VK

        #4
        Re: Problem with XmlHttpRequest (0x80040111 / nsIXMLHttpReque st.status) on several configurations


        Greg wrote:[color=blue]
        > Hi,
        >
        > I've designed a bookmark in Ajax / PHP that I will put soon on
        > sourceforge.net .
        > But I've got an very tricky bug.
        > I try it on some computers with Internet Explorer/Windows, Firefox
        > 1.07/Linux, Firefox 1.5/Linux, Firefox 1.5/Windows and Firefox 1.5/Mac,
        > Safari/Mac.
        > It works perfectly on a lot of configurations but, on some PC with
        > Firefox 1.5/Windows (not all), the Javascript code with XmlHttpRequest
        > don't work at all and I've got this message when I refresh the webpage
        > :
        > --------------------------------------------------------------------------------------
        > "Erreur : [Exception... "Component returned failure code: 0x80040111
        > (NS_ERROR_NOT_A VAILABLE) [nsIXMLHttpReque st.status]" nsresult:
        > "0x80040111 (NS_ERROR_NOT_A VAILABLE)" location: "JS frame ::
        > http://someWebServer/BookmarkAjax/js/requestor.js :: anonymous :: line
        > 52" data: no]
        > Fichier source : http://someWebServer/BookmarkAjax/js/requestor.js
        > Ligne : 52"
        > --------------------------------------------------------------------------------------
        >
        > Here is the source :
        > --------------------------------------------------------------------------------------
        > "function getReadyStateHa ndler(req, responseXmlHand ler) {
        > // Return an anonymous function that listens to the XMLHttpRequest
        > instance
        > return function () {
        > // If the request's status is "complete"
        > if (req.readyState == 4) {
        >
        > // Check that a successful server response was received[color=green][color=darkred]
        > >>> L.52 >>>> if (req.status == 200) {[/color][/color]
        >
        > // Pass the XML payload of the response to the
        > // handler function
        > var debug = document.getEle mentById("debug ");
        > debug.innerHTML += "<br/>" + req.status + " " + req.statusText;
        >
        > responseXmlHand ler(req.respons eXML);
        >
        > } else { ..."
        > --------------------------------------------------------------------------------------
        > This piece of source code comes from an IBM's article :
        > http://www-128.ibm.com/developerwork...dgr-lnxw01Ajax
        >
        > It's very strange because it is working on some configurations and not
        > at all on others, all based on Firefox 1.5/Windows....
        > There's a lot of message on the web about this kind of error but I
        > don't find this exactly case !
        > I would be glad if somebody could help me.
        > (I can give you an access on the web application by email if you wan't
        > to reproduce this bug)
        > Thanks - Greg[/color]

        Replace:
        if (req.status == 200)

        to:
        if (req.status == 200)||(req.stat us == 0))

        If it helps, ask my why (and you owe me a bottle of Bordeaux of a good
        year :-D

        Comment

        • Thomas 'PointedEars' Lahn

          #5
          Re: Problem with XmlHttpRequest (0x80040111 / nsIXMLHttpReque st.status) on several configurations

          VK wrote:
          [color=blue]
          > Replace:
          > if (req.status == 200)
          >
          > to:
          > if (req.status == 200)||(req.stat us == 0))[/color]

          `req.status' will never be 0 (and will never be converted to it implicitly,
          see ECMAScript Ed. 3, sections 11.9.1 and 11.9.1), there is no such status
          code in HTTP and the Microsoft IXMLHttpRequest interface reference, from
          which Gecko's XMLHttpRequest derives, does not suggest the property could
          hold this value or a value convertible to 0 ever. Therefore, the approach
          Ian suggested is, unfortunately unsurprisingly, more reasonable than this.

          <URL:http://msdn.microsoft. com/library/en-us/xmlsdk/html/f6de15fc-72e9-418e-b275-d94b0b2045de.as p>
          <URL:http://xulplanet.com/references/objref/XMLHttpRequest. html>


          PointedEars

          Comment

          • VK

            #6
            Re: Problem with XmlHttpRequest (0x80040111 / nsIXMLHttpReque st.status) on several configurations


            Thomas 'PointedEars' Lahn wrote:[color=blue]
            > `req.status' will never be 0 (and will never be converted to it implicitly,
            > see ECMAScript Ed. 3, sections 11.9.1 and 11.9.1)[/color]

            I'm wondering what do you have to say about Windows issues if you
            stated several times that you are under Linux? Unless you have Windows
            installed as well ? Are we cheating? ;-)

            FYI: using IXMLHTTPRequest for local (file:\\) files under Windows / IE
            6.x returns status 0 is success. So if the said bookmarklet used both
            for local and remote files, it may cause a hard to catch erratic
            behavior, because for local files status will never be 200 - despite
            the file itself will be perfectly loaded.
            Also as you cannot set Content-Type for file:\\ (at least for Windows),
            XML files loaded from harddrive do no trig XML parser (as it reacts on
            Content-Type only, not on file extension), so for your local .xml files
            responseXML is always "", only responseText is OK. That is another
            erratic behavior which may draw you crazy because the same file may
            parse just fine from server and "disappear" as soon as saved as local
            file.

            ECMAScript Ed. 3 doesn't know about it which is not a suprise of any
            kind.

            P.S. It is not the fact that it is the OP's problem, but something to
            start with. Another explanation can be in Firefox' bookmarlet security
            mechanics. We shall move on it if the above suggestion will fail.

            Comment

            • Greg

              #7
              Re: Problem with XmlHttpRequest (0x80040111 / nsIXMLHttpReque st.status) on several configurations

              Thanks for your replies but no one of your suggestions works...

              I'm 2 days at my parent's office and they have several PCs with windows
              and Firefox 1.5.
              It's almost strange because the application works on the server but
              doesn't on 2 'office' PCs.

              If I print the readyState like this :
              -------------------------------------------
              try {
              document.getEle mentById("conte nt").innerHTM L += req.readyState +
              '&nbsp;';
              if (req.readyState == 4) {
              if (req.status == 200) {
              responseXmlHand ler(req.respons eXML);
              } else {
              alert("HTTP error: "+req.statu s);
              }
              }
              } catch(e) {
              alert("Exceptio n : " + e);
              }
              -------------------------------------------
              I've got :
              - if it's working : 1 1 2 3 3 4
              - if not : 1 1

              And (on configuration wich it doesn't working), If I refresh the page,
              I caught the exception 0x80040111 (NS_ERROR_NOT_A VAILABLE)
              [nsIXMLHttpReque st.status]....

              I will try to debug this piece of code during the day. If I find a
              solution, I'll come back to you.

              By the way, this address book project is now on SourceForge :
              Download Gcontact for free. GContact is a Web based address book in Ajax/PHP : multi-user, multi-contacts (email,phone,icq,msn,...) & multi-address for each person, birthday reminder by email, mailing-list management, Excel export, ...

              But, for now, screens are only available in French.

              Comment

              • VK

                #8
                Re: Problem with XmlHttpRequest (0x80040111 / nsIXMLHttpReque st.status) on several configurations


                Greg wrote:[color=blue]
                > Thanks for your replies but no one of your suggestions works...
                >
                > I'm 2 days at my parent's office and they have several PCs with windows
                > and Firefox 1.5.
                > It's almost strange because the application works on the server but
                > doesn't on 2 'office' PCs.
                >
                > If I print the readyState like this :
                > -------------------------------------------
                > try {
                > document.getEle mentById("conte nt").innerHTM L += req.readyState +
                > '&nbsp;';
                > if (req.readyState == 4) {
                > if (req.status == 200) {
                > responseXmlHand ler(req.respons eXML);
                > } else {
                > alert("HTTP error: "+req.statu s);
                > }
                > }
                > } catch(e) {
                > alert("Exceptio n : " + e);
                > }
                > -------------------------------------------
                > I've got :
                > - if it's working : 1 1 2 3 3 4
                > - if not : 1 1
                >
                > And (on configuration wich it doesn't working), If I refresh the page,
                > I caught the exception 0x80040111 (NS_ERROR_NOT_A VAILABLE)
                > [nsIXMLHttpReque st.status]....[/color]

                The list line sounds really close to
                <http://ajaxtoolbox.com/forum/viewtopic.php?p =102&sid=f2be51 bc80038174198e5 f52e7d91554>

                Does it help anyhow if you do not use any req properties in
                else-brunch?

                Comment

                • Greg

                  #9
                  Re: Problem with XmlHttpRequest (0x80040111 / nsIXMLHttpReque st.status) on several configurations

                  No... Don't use req properties in else brunch doesn't help...
                  Thank for the link, I'm looking if it can help me...

                  Comment

                  • Greg

                    #10
                    Re: Problem with XmlHttpRequest (0x80040111 / nsIXMLHttpReque st.status) on several configurations

                    Wait !
                    Now, some HttpRequests are working !
                    But not on all functions on my application...
                    It's strange but now, I can look for differences between functions wich
                    are working and thoses which don't !
                    I think I will soon debug that problem !

                    Cool.

                    Comment

                    • Greg

                      #11
                      Re: Problem with XmlHttpRequest (0x80040111 / nsIXMLHttpReque st.status) on several configurations

                      I've found the problem !!!
                      It's because, when I don't have param to send, I'm sending some request
                      in this way : "req.send(null) ;"
                      And this don't work on some configurations !!!

                      If I use this : "req.send(' ');" (with space instead of null)
                      It's always work !!!!

                      What a stupid bug !

                      Comment

                      • VK

                        #12
                        Re: Problem with XmlHttpRequest (0x80040111 / nsIXMLHttpReque st.status) on several configurations


                        Greg wrote:[color=blue]
                        > I've found the problem !!!
                        > It's because, when I don't have param to send, I'm sending some request
                        > in this way : "req.send(null) ;"
                        > And this don't work on some configurations !!!
                        >
                        > If I use this : "req.send(' ');" (with space instead of null)
                        > It's always work !!!!
                        >
                        > What a stupid bug ![/color]

                        It is not really a bug AFAIK, but a difference between IXMLHTTPRequest
                        (Microsoft) and XMLHttpRequest (others). At least all MSDN samples seem
                        to go with "" and all Mozilla samples with null. Never studied it
                        profoundly though.

                        Comment

                        • bollax@hotmail.com

                          #13
                          Re: Problem with XmlHttpRequest (0x80040111 / nsIXMLHttpReque st.status) on several configurations

                          Can someone tell me why Firefox is not working with AJax and ONLY for
                          one of my scripts.

                          the error is
                          Error: [Exception... "Component returned failure
                          code: 0x80040111 (NS_ERROR_NOT_A VAILABLE) [nsIXMLHttpReque st.status]"
                          nsresult: "0x80040111 (NS_ERROR_NOT_A VAILABLE)" location: "JS frame ::
                          http://www.stepnstomp.co.uk/java/ajax.js :: alertContents :: line 41"
                          data: no]
                          Source File: /java/ajax.js
                          Line: 41
                          the code is
                          Code:
                              var http_request = false;
                          var retvars = "";
                          
                          function makeRequest(url, parameters, vars) {
                          http_request = false;
                          retvars = vars;
                          
                          if (window.XMLHttpRequest) { // Mozilla, Safari,...
                          http_request = new XMLHttpRequest();
                          if (http_request.overrideMimeType) {
                          http_request.overrideMimeType('text/xml');
                          // See note below about this line
                          }
                          } else if (window.ActiveXObject) { // IE
                          try {
                          http_request = new ActiveXObject("Msxml2.XMLHTTP");
                          } catch (e) {
                          try {
                          http_request = new
                          ActiveXObject("Microsoft.XMLHTTP");
                          } catch (e) {}
                          }
                          }
                          
                          if (!http_request) {
                          alert('AJAX - Giving up :( Cannot create an XMLHTTP
                          instance');
                          return false;
                          }
                          
                          http_request.onreadystatechange = alertContents;
                          http_request.open('POST', url, true);
                          http_request.setRequestHeader("Content-type",
                          "application/x-www-form-urlencoded");
                          http_request.setRequestHeader("Content-length",
                          parameters.length);
                          http_request.setRequestHeader("Connection", "close");
                          http_request.send(parameters);
                          
                          }
                          
                          function alertContents() {
                          
                          if (http_request.readyState == 4) {
                          if (xmlHttp.status == 0 || http_request.status == 200) {
                          // Call global AJAX function
                          
                          AJAX(http_request.responseText,retvars);
                          
                          } else {
                          alert('There is a problem with AJAX, please contact
                          support.');
                          }
                          }
                          
                          }
                          the script is this
                          Code:
                          #!/usr/bin/perl
                          
                          ######################
                          # Set Error Trapping #
                          ######################
                          
                          use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
                          use warnings;
                          use strict;
                          # use diagnostics;
                          
                          ##################
                          # Use SQL module #
                          ##################
                          use sql;
                          
                          # Set File DSN to use
                          $sql::DSN = "filedsn";
                          
                          # Read URL & Form data.
                          my %data = &get_data();
                          
                          # Get Tune
                          my @rs = &getSQL("Charts","UserID,Plays","UserID = '$data{'mp3'}'");
                          
                          # Update Plays
                          $rs[0]{'Plays'}++;
                          my $rec = &updSQL("Charts","Plays = $rs[0]{'Plays'}","UserID =
                          '$data{'mp3'}'");
                          
                          my $disp = $rs[0]{'Plays'};
                          
                          # Build Return AJAX data
                          my $catlist = "Content-type: text/html\n\n
                          $disp";
                          
                          # Print AJAX data
                          print $catlist;
                          exit();
                          
                          ########
                          the script runs ok as the DB gets updated, for some reason FF is
                          erroring when the data is returned. It works fine in IE and the same JS
                          is used in other places and works in FF, so why is this script playing
                          up?

                          Comment

                          • VK

                            #14
                            Re: Problem with XmlHttpRequest (0x80040111 / nsIXMLHttpReque st.status) on several configurations


                            bollax@hotmail. com wrote:[color=blue]
                            > Can someone tell me why Firefox is not working with AJax and ONLY for
                            > one of my scripts.
                            >
                            > the error is
                            Error: [Exception... "Component returned failure
                            > code: 0x80040111 (NS_ERROR_NOT_A VAILABLE) [nsIXMLHttpReque st.status]"
                            > nsresult: "0x80040111 (NS_ERROR_NOT_A VAILABLE)" location: "JS frame ::
                            > http://www.stepnstomp.co.uk/java/ajax.js :: alertContents :: line 41"
                            > data: no]
                            > Source File: /java/ajax.js
                            > Line: 41
                            >
                            > the code is
                            Code:
                                var http_request = false;
                            >     var retvars = "";
                            >
                            >     function makeRequest(url, parameters, vars) {
                            >         http_request = false;
                            >         retvars = vars;
                            >
                            >         if (window.XMLHttpRequest) { // Mozilla, Safari,...
                            >             http_request = new XMLHttpRequest();
                            >             if (http_request.overrideMimeType) {
                            >                 http_request.overrideMimeType('text/xml');
                            >                 // See note below about this line
                            >             }
                            >         } else if (window.ActiveXObject) { // IE
                            >             try {
                            >                 http_request = new ActiveXObject("Msxml2.XMLHTTP");
                            >             } catch (e) {
                            >                 try {
                            >                     http_request = new
                            > ActiveXObject("Microsoft.XMLHTTP");
                            >                 } catch (e) {}
                            >             }
                            >         }
                            >
                            >         if (!http_request) {
                            >             alert('AJAX - Giving up :( Cannot create an XMLHTTP
                            > instance');
                            >             return false;
                            >         }
                            >
                            >       http_request.onreadystatechange = alertContents;
                            >       http_request.open('POST', url, true);
                            >       http_request.setRequestHeader("Content-type",
                            > "application/x-www-form-urlencoded");
                            >       http_request.setRequestHeader("Content-length",
                            > parameters.length);
                            >       http_request.setRequestHeader("Connection", "close");
                            >       http_request.send(parameters);
                            >
                            >     }
                            >
                            >     function alertContents() {
                            >
                            >         if (http_request.readyState == 4) {
                            >             if (xmlHttp.status == 0 || http_request.status == 200) {
                            >                 // Call global AJAX function
                            >
                            >                 AJAX(http_request.responseText,retvars);
                            >
                            >             } else {
                            >                 alert('There is a problem with AJAX, please contact
                            > support.');
                            >             }
                            >         }
                            >
                            >     }
                            >
                            > the script is this
                            Code:
                            #!/usr/bin/perl
                            >
                            > ######################
                            > # Set Error Trapping #
                            > ######################
                            >
                            > use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
                            > use warnings;
                            > use strict;
                            > # use diagnostics;
                            >
                            > ##################
                            > # Use SQL module #
                            > ##################
                            > use sql;
                            >
                            > # Set File DSN to use
                            > $sql::DSN = "filedsn";
                            >
                            > # Read URL & Form data.
                            > my %data = &get_data();
                            >
                            > # Get Tune
                            > my @rs = &getSQL("Charts","UserID,Plays","UserID = '$data{'mp3'}'");
                            >
                            > # Update Plays
                            > $rs[0]{'Plays'}++;
                            > my $rec = &updSQL("Charts","Plays = $rs[0]{'Plays'}","UserID =
                            > '$data{'mp3'}'");
                            >
                            > my $disp = $rs[0]{'Plays'};
                            >
                            > # Build Return AJAX data
                            > my $catlist = "Content-type: text/html\n\n
                            > $disp";
                            >
                            > # Print AJAX data
                            > print $catlist;
                            > exit();
                            >
                            > ########
                            >
                            > the script runs ok as the DB gets updated, for some reason FF is
                            > erroring when the data is returned. It works fine in IE and the same JS
                            > is used in other places and works in FF, so why is this script playing
                            > up?[/color]

                            This may (or may not) help:

                            <https://bugzilla.mozill a.org/show_bug.cgi?id =238559>
                            <quote>
                            Mozilla calls onload() for all HTTP transactions that succeeded. The
                            only
                            time it calls onerror() is when a network error happened. Inside the
                            onerror
                            handler, accessing the status attribute results in this exception:

                            Error: [Exception... "Component returned failure code: 0x80040111
                            (NS_ERROR_NOT_A VAILABLE) [nsIXMLHttpReque st.status]" nsresult:
                            "0x80040111
                            (NS_ERROR_NOT_A VAILABLE)" location: "JS frame ::
                            </quote>

                            Moral: for Gecko XMLHttpRequest implementation you seem not allowed to
                            study Ajax object in onerror handler as any attempt to read its
                            property raise an error.

                            Comment

                            • bollax@hotmail.com

                              #15
                              Re: Problem with XmlHttpRequest (0x80040111 / nsIXMLHttpReque st.status) on several configurations

                              > This may (or may not) help:[color=blue]
                              >
                              > <https://bugzilla.mozill a.org/show_bug.cgi?id =238559>
                              > <quote>
                              > Mozilla calls onload() for all HTTP transactions that succeeded. The
                              > only
                              > time it calls onerror() is when a network error happened. Inside the
                              > onerror
                              > handler, accessing the status attribute results in this exception:
                              >
                              > Error: [Exception... "Component returned failure code: 0x80040111
                              > (NS_ERROR_NOT_A VAILABLE) [nsIXMLHttpReque st.status]" nsresult:
                              > "0x80040111
                              > (NS_ERROR_NOT_A VAILABLE)" location: "JS frame ::
                              > </quote>
                              >
                              > Moral: for Gecko XMLHttpRequest implementation you seem not allowed to
                              > study Ajax object in onerror handler as any attempt to read its
                              > property raise an error.[/color]

                              Thanks for the reply, i'm not a JS expert and alot didn't make sense to
                              me, but what really doesn't make sense is, the JS I wrote above is a
                              global file that ALL my AJAX requests use.

                              So this line : if (http_request.s tatus == 200) where it is erroring is
                              called all the time, I'm only getting an error for 1 of my scripts.

                              This to me is indicating that the returned data is different to other
                              data returned as those requests don't give me this error.

                              I could understand if FireFox always errored everytime for that line,
                              but it doesn't, so there has to be something else going on.

                              It's not because the network/server is unvailable, as the script called
                              runs and the database gets updated.

                              I can't see what is different between the scripts that work and the ONE
                              that doesn't.

                              Comment

                              Working...