SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    AJAX calls not working in new version of Firefox

    Is this happening to anyone else? In Safari, IE and previous version of FF all my calls work fine but when I upgrade to the new Firefox, it "hangs". The calls are made, but nothing is returned to the screen.

  2. #2
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    On POST requests or GET requests? FF 3.0.x fires the onload event instead of onreadystatechange for synchronous POST requests. Just because they can, I guess.

    EDIT: Here's some workaround code:

    Code:
    if ((xhr.async == false) && (navigator.userAgent.indexOf('Gecko') != -1)) xhr.onload = function() {handleResponse();};
    else xhr.onreadystatechange = function() {handleResponse();};

  3. #3
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by World Wide Weird View Post
    On POST requests or GET requests? FF 3.0.x fires the onload event instead of onreadystatechange for synchronous POST requests. Just because they can, I guess.

    EDIT: Here's some workaround code:

    Code:
    if ((xhr.async == false) && (navigator.userAgent.indexOf('Gecko') != -1)) xhr.onload = function() {handleResponse();};
    else xhr.onreadystatechange = function() {handleResponse();};
    Thanks for the snippet, but where does it go?

    In this block:

    xmlHttp.onreadystatechange = function()
    {
    if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
    {
    eval(myFunc2) (xmlHttp.responseXML,thisID,thisTagName);
    }
    }

    I assume the xhr is the xmlHTTP object, right?

  4. #4
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Webspeeder View Post
    Thanks for the snippet, but where does it go?
    Put it wherever you would normally declare the onreadystatechange handler for the XMLHttpRequest object, and use it the same way. The only difference is, you're implementing a cross-browser version.

    Quote Originally Posted by Webspeeder View Post
    I assume the xhr is the xmlHTTP object, right?
    Correct.

  5. #5
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This still isn't working. Here is what I've done.
    BEGIN OLD Code
    xmlHttp.onreadystatechange = function()
    {
    if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
    {
    eval(myFunc2) (xmlHttp.responseXML,thisID,thisTagName);
    }
    }
    END Old Code
    New Code
    if ((xmlHttp.async == false) && (navigator.userAgent.indexOf('Gecko') != -1))
    xmlHttp.onload = function()
    {
    if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
    {
    eval(myFunc2) (xmlHttp.responseXML,thisID,thisTagName);
    }
    }
    else
    xmlHttp.onreadystatechange = function()
    {
    if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete")
    {
    eval(myFunc2) (xmlHttp.responseXML,thisID,thisTagName);
    }
    }
    END new Code

    I'm missing something but I don't know what....

  6. #6
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The responseXML above is responseText....

  7. #7
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, I gather your problem has nothing to do with FF using the onload event for synchronous POST requests then. I'll need to see the full context to determine what else is at play here.

  8. #8
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, that'll teach me to cut and paste. I had two functions, one for XML and one for HTML and the eval() was sending parms for XML call.

    I got it working. Thanks for your help....


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •