annoying javascript error

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

    annoying javascript error

    Hello all I am new to javascript and I am attempting to write a site in
    JS / PHP to jump on the ajax band wagon. I am getting the following
    error and have not been able to locate a solution for it yet. From
    what I have read some people say it could have to do with xmlrequest
    being busy or something like that.

    Error: [Exception... "Component returned failure code: 0xc1f30001
    (NS_ERROR_NOT_I NITIALIZED) [nsIXMLHttpReque st.send]" nsresult:
    "0xc1f30001 (NS_ERROR_NOT_I NITIALIZED)" location: "JS frame :: mysite
    :: getImage :: line 37" data: no]
    Source File: mysite
    Line: 37

    thanks!

  • Randy Webb

    #2
    Re: annoying javascript error

    seanism said the following on 5/14/2006 2:04 PM:[color=blue]
    > Hello all I am new to javascript and I am attempting to write a site in
    > JS / PHP to jump on the ajax band wagon.[/color]

    Oh geez, another one.
    [color=blue]
    > I am getting the following error and have not been able to locate a
    > solution for it yet. From what I have read some people say it could
    > have to do with xmlrequest being busy or something like that.[/color]

    Or one of another million SWAG's one could make.
    [color=blue]
    > Error: [Exception... "Component returned failure code: 0xc1f30001
    > (NS_ERROR_NOT_I NITIALIZED) [nsIXMLHttpReque st.send]" nsresult:
    > "0xc1f30001 (NS_ERROR_NOT_I NITIALIZED)" location: "JS frame :: mysite
    > :: getImage :: line 37" data: no]
    > Source File: mysite
    > Line: 37[/color]

    My stereo doesn't work. Why?

    The point being, you can't determine whats wrong with code that you
    can't see.

    --
    Randy
    comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

    Comment

    • seanism

      #3
      Re: annoying javascript error

      very true indeed.

      <script type="text/javascript">
      <!--
      var results;

      function vote(user_id, v){
      // Build the URL to connect to
      var url = "vote_ajax.php? id=" + results[0] + "&user_id=" + user_id +
      "&vote=" + v;
      request.abort() ;
      // Open a connection to the server
      request.open("G ET", url, true);

      // Setup a function for the server to run when it's done
      request.onready statechange = window.location .reload( true );

      // Send the request
      request.send(nu ll);
      }

      function getImage(){
      // Build the URL to connect to
      var url = "image_ajax.php ";
      // Open a connection to the server
      request.open("G ET", url, true);

      // Setup a function for the server to run when it's done
      request.onready statechange = changeImage;

      // Send the request
      request.send(nu ll);
      }

      function changeImage(){
      if (request.readyS tate == 4) {
      // Split the comma delimited response into an array
      results = request.respons eText.split("," );
      document.getEle mentById('image ').innerHTML = results[2];
      }

      }
      //-->
      </script>

      Comment

      • seanism

        #4
        Re: annoying javascript error

        var request = false;
        try{
        // Mozilla/Safari
        if (window.XMLHttp Request)
        request = new XMLHttpRequest( );
        // IE
        else if (window.ActiveX Object)
        request = new ActiveXObject(" Microsoft.XMLHT TP");
        }
        catch (e) {
        alert(e);
        }
        // Error

        if(!request)
        alert("XHR Object cannot create");

        Comment

        • Randy Webb

          #5
          Re: annoying javascript error

          seanism said the following on 5/14/2006 8:50 PM:

          Please quote what you are replying to.

          If you want to post a followup via groups.google.c om, don't use the
          "Reply" link at the bottom of the article. Click on "show options" at
          the top of the article, then click on the "Reply" at the bottom of the
          article headers.

          <URL: http://www.safalra.com/special/googlegroupsreply/ >
          [color=blue]
          > very true indeed.[/color]

          Post a URL to a full sample page that displays the behavior and what
          steps produce the error.
          --
          Randy
          comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
          Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

          Comment

          • seanism

            #6
            Re: annoying javascript error

            rgr that Randy. Should I reply on the top or bottom of the quoted
            information? Also is there an easy way to see what threads you
            started? If I goto my profile it shows some on the bottom but I was
            thinking that they would make it easier then that? I starred the
            articles that I started to see them on the my posts link.

            as far as the site its www.stoneorbone.com right now it works because
            instead of calling the getImage function I just have it do a JS refresh
            of the page.

            Randy Webb wrote:[color=blue]
            > seanism said the following on 5/14/2006 8:50 PM:
            >
            > Please quote what you are replying to.
            >
            > If you want to post a followup via groups.google.c om, don't use the
            > "Reply" link at the bottom of the article. Click on "show options" at
            > the top of the article, then click on the "Reply" at the bottom of the
            > article headers.
            >
            > <URL: http://www.safalra.com/special/googlegroupsreply/ >
            >[color=green]
            > > very true indeed.[/color]
            >
            > Post a URL to a full sample page that displays the behavior and what
            > steps produce the error.
            > --
            > Randy
            > comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
            > Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/[/color]

            Comment

            • Randy Webb

              #7
              Re: annoying javascript error

              seanism said the following on 5/16/2006 2:10 PM:[color=blue]
              > rgr that Randy. Should I reply on the top or bottom of the quoted
              > information?[/color]

              What do most in this group do and what does that FAQ/Notes say with
              regards to that?

              Hint: Pay attention to how my reply is done.
              [color=blue]
              > Also is there an easy way to see what threads you started?[/color]

              For me, yes. But, I don't use Google Groups. Ask a Google Groups person.
              [color=blue]
              > If I goto my profile it shows some on the bottom but I was
              > thinking that they would make it easier then that? I starred the
              > articles that I started to see them on the my posts link.[/color]

              <shrug> No idea as I don't use Google Groups.
              [color=blue]
              > as far as the site its www.stoneorbone.com right now it works because
              > instead of calling the getImage function I just have it do a JS refresh
              > of the page.[/color]

              Well, you know the getImage() function works properly or you would get
              errors when it gets triggered onload.

              All of that code looks like a hard way to do something. What exactly is
              it that you are trying to do with it? Let someone vote, post the vote,
              then retrieve an image? But then you split that image and only use part
              of it. Why not just have the PHP return the plain HTML code you want to use?

              --
              Randy
              comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
              Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

              Comment

              • Thomas 'PointedEars' Lahn

                #8
                Re: annoying javascript error

                seanism wrote:
                [color=blue]
                > var request = false;[/color]

                `request' is used as an object reference. It should be initialized
                with `null' (null reference), not the boolean value `false'.
                [color=blue]
                > try{[/color]

                There is no need for try...catch for XMLHttpRequest, only for ActiveXObject.
                In fact, using too much exception handling can prevent you from catching
                your bugs.
                [color=blue]
                > // Mozilla/Safari
                > if (window.XMLHttp Request)[/color]

                You are feature-testing the mere _existence_ (to be more exact: the
                _true-value_) of a property of _`window'_ ...
                [color=blue]
                > request = new XMLHttpRequest( );[/color]

                .... but you _construct_ with a _method_ of the _Global Object_.
                Furthermore, you do not declare `request', and so it becomes a property of
                the Global Object, /iff/ there is no other object in the scope chain where
                this applies to. Both approaches are error-prone.
                [color=blue]
                > // IE
                > else if (window.ActiveX Object)
                > request = new ActiveXObject(" Microsoft.XMLHT TP");[/color]

                Same here.
                [color=blue]
                > }
                > catch (e) {
                > alert(e);
                > }[/color]

                Your code style allows for improvement. For example, do not use tabs;
                use spaces.
                [color=blue]
                > // Error
                >
                > if(!request)
                > alert("XHR Object cannot create");[/color]

                The content of those message boxes is useless to Joe User, so you better
                make them debug messages only.

                var _global = this;

                function isMethod(a)
                {
                return a && /\b(function|obj ect)\b/.test(typeof a);
                }

                function getImage()
                {
                var request = null;

                if (isMethod(_glob al.XMLHttpReque st))
                {
                request = new XMLHttpRequest( );
                }
                else if (isMethod(_glob al.ActiveXObjec t))
                {
                try
                {
                request = new ActiveXObject(" Microsoft.XMLHT TP");
                }
                catch (e)
                {
                // ...
                }
                }

                if (request)
                {
                // ...
                }
                else
                {
                // ...
                }

                return request;
                }


                PointedEars
                --
                This above all: To thine own self be true.
                -- William Shakespeare (1564-1616)

                Comment

                • Thomas 'PointedEars' Lahn

                  #9
                  Re: annoying javascript error

                  seanism wrote:
                  [color=blue]
                  > Error: [Exception... "Component returned failure code: 0xc1f30001
                  > (NS_ERROR_NOT_I NITIALIZED) [nsIXMLHttpReque st.send]" nsresult:
                  > "0xc1f30001 (NS_ERROR_NOT_I NITIALIZED)" location: "JS frame :: mysite
                  > :: getImage :: line 37" data: no]
                  > Source File: mysite
                  > Line: 37[/color]

                  First Google hit for this error code:

                  <URL:http://www.quirksmode. org/blog/archives/2005/09/xmlhttp_notes_a _1.html>


                  PointedEars

                  Comment

                  • Randy Webb

                    #10
                    Re: annoying javascript error

                    Thomas 'PointedEars' Lahn said the following on 5/22/2006 11:26 AM:[color=blue]
                    > seanism wrote:
                    >[color=green]
                    >> var request = false;[/color]
                    >
                    > `request' is used as an object reference. It should be initialized
                    > with `null' (null reference), not the boolean value `false'.[/color]

                    Either one satisfies the requirements of the test that is used on it.
                    [color=blue][color=green]
                    >> try{[/color]
                    >
                    > There is no need for try...catch for XMLHttpRequest, only for ActiveXObject.
                    > In fact, using too much exception handling can prevent you from catching
                    > your bugs.[/color]

                    Absolutely.
                    [color=blue][color=green]
                    >> // Mozilla/Safari
                    >> if (window.XMLHttp Request)[/color]
                    >
                    > You are feature-testing the mere _existence_ (to be more exact: the
                    > _true-value_) of a property of _`window'_ ...
                    >[color=green]
                    >> request = new XMLHttpRequest( );[/color]
                    >
                    > .... but you _construct_ with a _method_ of the _Global Object_.[/color]

                    So what?
                    [color=blue]
                    > Furthermore, you do not declare `request', and so it becomes a property of
                    > the Global Object, /iff/ there is no other object in the scope chain where
                    > this applies to. Both approaches are error-prone.[/color]

                    Now, once again, please name a browser that does not implement the
                    window as the Global Object. And especially a browser that supports
                    window.XMLHttpR equest where window isn't the Global Object.

                    Your ranting about window not being the Global Object gets old.
                    [color=blue]
                    > Your code style allows for improvement. For example, do not use tabs;
                    > use spaces.[/color]

                    There are problems with the posting style, but the coding style is
                    perfectly acceptable. Code any way you want, just pretty it up to post
                    it to Usenet.
                    [color=blue][color=green]
                    >> // Error
                    >>
                    >> if(!request)
                    >> alert("XHR Object cannot create");[/color]
                    >
                    > The content of those message boxes is useless to Joe User, so you better
                    > make them debug messages only.
                    >
                    > var _global = this;[/color]

                    Unneeded Global Variable.
                    [color=blue]
                    > function isMethod(a)
                    > {
                    > return a && /\b(function|obj ect)\b/.test(typeof a);
                    > }
                    >
                    > function getImage()
                    > {
                    > var request = null;
                    >
                    > if (isMethod(_glob al.XMLHttpReque st))[/color]

                    Nonsense test.
                    [color=blue]
                    > {
                    > request = new XMLHttpRequest( );
                    > }
                    > else if (isMethod(_glob al.ActiveXObjec t))[/color]

                    Nonsense test.

                    But, once again, nothing you posted had anything to do with the problem.

                    --
                    Randy
                    comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
                    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

                    Comment

                    • acedanger
                      New Member
                      • Jul 2006
                      • 1

                      #11
                      I wrote a blog post about this error. Basically, the error means that you are trying to use a request object that is already being used or is busy. I could be wrong but I made a work-around: created a second request object if the first is busy.

                      Error post: http://blog.petewood.us/2006/05/19/n...-ajax-enabled/

                      Error fix post:


                      Hope this helps...if you haven't figured out a solution already.

                      Comment

                      Working...