Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Ajax
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Ajax the combination of XHTML, CSS, DOM, XML, XSLT, XMLHttpRequest, and JavaScript
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Ajax section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 20th, 2007, 09:56 AM
Registered User
 
Join Date: Aug 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Mozilla onreadystatechange incompatibility

Okay, I'm fried... I've been hammering on this for days and I can't figure it out... Code's going all spaghetti on me...

This works in IE but updates do not happen in Mozilla 2.0.0.6.

Scriptaculous library (1.7.1_beta3), Prototype (1.6.0_rc0) and zXML 1.0.2 are being used. Scriptaculous is being used to autopopulate a field. Once that field is selected, an updateElement call is made to "getData" (this function). This function then goes and fires a whole bunch of asychronous calls to the server to load data.

In IE, it gets all of the way through it... In Moz 2.0.0.6 it never gets into the onreadystate function even though the readystate does change from 1 to 4 and it does get a status of 200.

My guess is that the event is never getting called in Mozilla so it's never getting into the oXmlHttp.onreadystatechange function.

Ideas?

THanks!



Code:
  function getData(fullAddress)
   {
    var fullAddressElement = document.getElementById("fullAddress");
    fullAddressElement.value = fullAddress.innerHTML;

    whereFieldElement = document.getElementById("whereField");

    var whereField = whereFieldElement.value;

    for (var x = 0; x <= document.dataEntry.length-1; x++)
     {
      var getElement = document.getElementById(document.dataEntry.elements[x].name);
      var get = getElement.name;
      var where = whereField + "='"+ fullAddressElement.value +"'";

      var oXmlHttp = zXmlHttp.createRequest();
      oXmlHttp.open("GET", "getValue.php?get=" + get + "&where=" + where, false);
           alert (oXmlHttp.readyState);
      oXmlHttp.onreadystatechange = function ()
       {
        if (oXmlHttp.readyState == 4)
         {
          alert ("in state -"+ oXmlHttp.readyState +"-");
          if (oXmlHttp.status == 200)
           {
            getElement.value = oXmlHttp.responseText;
           }
          else
           {
            alert ("An error occurred: " + oXmlHttp.statusText); //statusText is not always accurate
           }
         }
       };
           alert (oXmlHttp.readyState);

      oXmlHttp.send(null);
           alert (oXmlHttp.readyState);
           alert (oXmlHttp.status);
     }
   }
Reply With Quote
  #2 (permalink)  
Old August 20th, 2007, 10:22 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You normally use onreadystatechange with an async call, have you tried setting the third parameter of the open method to true?

--

Joe (Microsoft MVP - XML)
Reply With Quote
  #3 (permalink)  
Old August 20th, 2007, 11:38 AM
Registered User
 
Join Date: Aug 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Joe,

I left it async and removed the event capture and it works in IE and Moz. Question...

If I do it sync in Mozilla, and I slow it down with the alerts, it works. If I do not slow it down, it only gets the last one...

Why is that? Is there something I don't understand about event capture? Is it funky in Moz?

Thanks!

Reply With Quote
  #4 (permalink)  
Old August 21st, 2007, 02:04 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

If I recall correctly Mozilla/Gecko doesn't natively support all the states that IE does, zXml tries to emaulate it but it can only really be completed or not. The normal pattern for Ajax is to use an asynchronous call, otherwise it would be called Sjax :)

--

Joe (Microsoft MVP - XML)
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
incompatibility of versions. Vilariño ASP.NET 1.0 and 1.1 Basics 0 March 8th, 2007 09:52 AM
Browszer incompatibility neuropathie ASP.NET 1.0 and 1.1 Professional 1 July 11th, 2006 07:44 AM
pasteHTML() for mozilla ? Farooq Javascript 0 December 21st, 2005 07:39 AM
Incompatibility Linux-Windows jguillen Pro PHP 3 April 19th, 2005 06:49 AM
MSXML2.XMLHTTP40. OnReadyStateChange won't work LarryT Access VBA 0 August 8th, 2004 05:28 PM



All times are GMT -4. The time now is 02:34 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.