Firefox - 'undefined' error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pravinasp
    New Member
    • Oct 2007
    • 20

    Firefox - 'undefined' error

    I have a page with table layout which has an AJAX request sent on body onLoad event, during this time the table cells show static text like "Loading". The table cells are later updated with the AJAX response. So when I try to move out of the page once the AJAX request is sent by clicking on a link for exmple, the "Loading" changes to "undefined" . I read that innerHTML is not supported by firefox for table cells so i started using div inside the table cell yet no result. However IE and Opera seems to work fine. could anyone please tell me where am going wrong ?? Thanks a ton
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Post your code so we can see where the problem might lie.

    Comment

    • pravinasp
      New Member
      • Oct 2007
      • 20

      #3
      Thanks for your reply, The ajaxrequest is triggered by the following functions

      Code:
      function getReportStatus(geturl)
      {
         var columnvals;
         var filtervals;
         url = geturl;
         xmlObj = null;
         xmlObj = GetXmlObj(); 
      // This function is to choose the right xmlhttp object according to the browser
         xmlObj.onreadystatechange=stateChanged;
         xmlObj.open("GET", url , true);
         xmlObj.send(null);
      
      }
      
      function stateChanged()
       {
           if (xmlObj.readyState==4 || xmlObj.readyState=="complete")
           {
               data = xmlObj.responseText;
               var data_split = data.split("|");
      
                document.getElementById("citystate").innerHTML= data_split[0];
                document.getElementById("progress").innerHTML = data_split[1];
                document.getElementById("function").innerHTML= data_split[2];
      
               // All the ids above are div element ids which are inside individual <td> elements
      
           }
      /*
           else if(xmlObj.readyState==1)
           {
              document.getElementById("citystate").innerHTML = "HEY";
              document.getElementById("progress").innerHTML = "Loading";
              document.getElementById("function").innerHTML = "Loading";
           }
           else if(xmlObj.readyState==3)
           {
              document.getElementById("citystate").innerHTML = "HEY";
              document.getElementById("progress").innerHTML = "Loading";
              document.getElementById("function").innerHTML = "Loading";
           }
      */
        }
      Please let me know if you need any other piece of code as well.


      Cheers

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        I'll also need to see the relevant HTML code. If the code is too much and you have a test site link, post that instead.

        Comment

        • pravinasp
          New Member
          • Oct 2007
          • 20

          #5
          Is it possible i can email you my test site?? I dont want it to be public

          Thanks again

          Originally posted by acoder
          I'll also need to see the relevant HTML code. If the code is too much and you have a test site link, post that instead.

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            PM me instead.

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              I've had a look, but I am unable to reproduce the problem.

              Can you give me some exact steps to trigger the error.

              Comment

              • pravinasp
                New Member
                • Oct 2007
                • 20

                #8
                once you click the button 'Create Report' you will be inside the report center. Once you are are inside the report center, click on any link just to navigate away from the page. When you click on the link the the table cells which were saying 'Loading' would disappear and you will see 'undefined' appearing in those cells for a very brief time before you end up in the next page.Please let me know if you were able to reproduce it this time. Thanks for your efforts again.

                Comment

                • pravinasp
                  New Member
                  • Oct 2007
                  • 20

                  #9
                  hey were you able to reproduce error now??

                  Comment

                  • acoder
                    Recognized Expert MVP
                    • Nov 2006
                    • 16032

                    #10
                    Yes, it seems it's only triggered if you leave the page.

                    I'm not sure what might be triggering it, but perhaps you need to abort the request onunload.

                    Comment

                    • pravinasp
                      New Member
                      • Oct 2007
                      • 20

                      #11
                      Cool, thanks a lot. I would have a go at it and let you know. Appreciate the time you had spent on this.

                      Cheers

                      Comment

                      • Plater
                        Recognized Expert Expert
                        • Apr 2007
                        • 7872

                        #12
                        I have noticed on FF a lot when using the FireBug addon that it shows various javascript functions as "undefined" when you attempt to navigate away from a page, that might have pending javascript code running.

                        Comment

                        • pravinasp
                          New Member
                          • Oct 2007
                          • 20

                          #13
                          I dont think FireBug is the issue in my case, as it shows 'undefined' even in other boxes with no firebug on.

                          Comment

                          • acoder
                            Recognized Expert MVP
                            • Nov 2006
                            • 16032

                            #14
                            Originally posted by acoder
                            Yes, it seems it's only triggered if you leave the page.

                            I'm not sure what might be triggering it, but perhaps you need to abort the request onunload.
                            The XMLHttpRequest object has an abort() method which you can use or set the variable to null. Just make sure that the request hasn't already finished. If it has, then there's nothing to worry about anyway.

                            Comment

                            • Plater
                              Recognized Expert Expert
                              • Apr 2007
                              • 7872

                              #15
                              Well I get the undefined error for other functions that have no relation to the xmlhttprequest stuff. They shouldn't even be being accessed, but firebug still likes to throw errors for it.

                              Comment

                              Working...