?
Solved

onreadystatechange trigger in Firefox 2.0

Posted on 2006-11-23
4
Medium Priority
?
251 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
Suggested Courses

765 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