Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

onreadystatechange trigger in Firefox 2.0

Posted on 2006-11-23
4
Medium Priority
?
252 Views
Last Modified: 2006-11-24
In an effort to learn about AJAX I found several similar examples and created a demo program.  The problem seems to occur in the segment shown below.
- - - - - - - - - - - - - - - - - - - -
<script language="javascript">

var http = new XMLHttpRequest();

function sndReq(action) {
      http.onreadystatechange = handleResponse;
      http.open('GET', 'ajtestprocessor.php?action='+action, false);
      http.send(null);

</script>
- - - - - - - - - - - - - - - - - - - -
I can insert alert statements and watch http.readyState change from 0 (uninitialized), to 2 (loaded), and then to 4 (complete).  In Firefox 2.0 the onreadystatechange trigger fires only once (on the 0 to 1 transition) while in Opera 9.1 it appears to fire on each transition.  From other languages and from the coding of the AJAX examples, the behavior of Opera is what I would expect.  Is Firefox handling this trigger properly?  Do I need to somehow reset the trigger in the 'handleResponse' function?

Thanks.
0
Comment
Question by:ttheimer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 7

Expert Comment

by:vbandaru
ID: 18004613
If you make the asynchrouns flag to true, it does fire for all states.
0
 
LVL 7

Accepted Solution

by:
vbandaru earned 1000 total points
ID: 18004640
Okay here is what i found and it makes sense. if the asynchronous flag is set to false as in your case, There is no point in monitoring the ready state. The code just waits untill it recieves a response back (readystate=4) from the send method. The 0to 4 transition is something that cannot be monitored.

I agree that opera and I.E still track that but this seems to be a browser specific  implementation.

Hope that helps!!
0
 
LVL 17

Expert Comment

by:gops1
ID: 18006504
I think responding to ready states varies from browser to browser.

You can go to this URL : http://www-128.ibm.com/developerworks/web/library/wa-ajaxintro2/index.html

and refer, HTTP ready states
0
 
LVL 7

Expert Comment

by:vbandaru
ID: 18007807
gops1 ,
The article does not describe states when the asynch flag is false.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question