Handler Does not work in Firefox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Herkum
    New Member
    • Nov 2007
    • 2

    Handler Does not work in Firefox

    I created this generic AJAX Handler to work with Firefox and IE. However, it seems that somewhere in updating Firefox to 2.0.0.9 that the handler assigned to onreadystatecha nge is no longer getting called. This still works for IE.

    Can someone help me add to this so that I can get it working with Firefox again?

    Code:
    var ASYNCH       = true;
    var REQUEST_TYPE = 'POST';
    var AJAX_URL     = '/ajax.cgi';
    
    function httpRequest() {
        // Mozilla-based browsers
        if (window.XMLHttpRequest) {
            ajaxRequest = new XMLHttpRequest();
        }
        // IE-based browsers
        else if (window.ActiveXObject) {
            ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
    
            if(! this.ajaxRequest) {
                ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
            }
        }
        // The request could still be null if neither ActiveXObject
        // initialization succeeded
        if (! ajaxRequest) {
            alert("Your browser does not permit the use of all of this " +
                "application's features");
            return false;
        }
        ajaxRequest.onreadystatechange = this.handler; // DOES NOT WORK IN Firefox 2.0.0.9
        ajaxRequest.open( REQUEST_TYPE, AJAX_URL, ASYNCH);
        ajaxRequest.setRequestHeader("Content-Type",
            "application/x-www-form-urlencoded; charset=UTF=-8"
        );
        ajaxRequest.send( this.queryString );
        return true;
    }
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Could you post the code for the handler?

    Comment

    • Herkum
      New Member
      • Nov 2007
      • 2

      #3
      Originally posted by acoder
      Could you post the code for the handler?
      I think I did not make myself clear, the handler never gets called in Firefox. It works perfectly in IE and it HAD worked in Firefox before I upgraded it. So it is something specific to recent versions of Firefox.

      I was hoping someone could help add some code to handle the problem that is occurring specifically to Firefox.

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        hi ...

        have a look at the FF javascript-console ... are there any errors?

        kind regards

        Comment

        • Fabiano

          #5
          Friends, try remove the code line follow:

          ajaxRequest.onr eadystatechange = this.handler;

          I tried it, and this works perfectly at the FF, Chrome and IE 6, 7 and 8.

          Kind regards.

          Comment

          • gits
            Recognized Expert Moderator Expert
            • May 2007
            • 5390

            #6
            then there is no response-handler?? how ist the response handled now?

            this.handler in the original post had to be a handler-function which would have been to be declared for the custom httpRequest function/object ... and it is missing in the posted code ... at least there should be something like:

            Code:
            ajaxRequest.onreadystatechange = function(response) {
                // do something with response
            };

            Comment

            Working...