Firefox - 'undefined' error

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

    #16
    I tried nulling the xmlhttp object, but still remains the same. I dont really understand how the error gets triggered. Not all the table cells show undefined, only two columns does that. The other column which is also updated with the AJAX response goes blank instead of saying undefined. There are no differences between these columns though. I cant think of a reason why firefox would do it... any suggestions??

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #17
      If you try to call a method/function on an object that doesn't support it, you frequently are returned "undefined"
      Like trying to use TOSTRING() vs toString() and such.

      Comment

      • pravinasp
        New Member
        • Oct 2007
        • 20

        #18
        Problem sorted,

        " xmlObj.readySta te == "4" || xmlObj.readySta te=="complete" "

        This is the line that had the problem. The readyState receives only a numeric response and no string. So this was breaking the script here when i compare readyState to "Complete" and was returning an empty responseText all the time. So when i tried to split responseText and add it to the div elements the first element went null and the others were saying undefined.

        Any explanation on why this would break in firefox alone would be appreciated.


        Thanks for all your help guys

        Cheers

        Comment

        • Plater
          Recognized Expert Expert
          • Apr 2007
          • 7872

          #19
          IE "doesn't care"?
          Also, I notice that in IE, the ready state will be set to a winsock error code number when such events arrive (like host not found), whereas FF throws a javascript exception. So be sure to use try/catch statements.

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #20
            Did you have it as:
            xmlObj.readySta te == "4" (string) or
            xmlObj.readySta te == 4 (integer)?

            Comment

            • pravinasp
              New Member
              • Oct 2007
              • 20

              #21
              sorry my bad, i have it as an integer not like the previous post.

              xmlObj.readySta te == 4
              (integer).

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #22
                I'm not sure which browsers require "complete", but you should also add in a check for status, i.e.
                [code=javascript]if (xmlObj.readySt ate == 4 || xmlObj.readySta te == "complete") {
                if (xmlObj.status == 200) { // OK
                // now it's ready...[/code]

                Comment

                • pravinasp
                  New Member
                  • Oct 2007
                  • 20

                  #23
                  exactly now i have added status check and its working fine now.

                  Thanks for your help, much appreciated.

                  Cheers

                  Comment

                  • acoder
                    Recognized Expert MVP
                    • Nov 2006
                    • 16032

                    #24
                    You're welcome. Glad it's all working fine now. A simple solution in the end.

                    Comment

                    Working...