Solved

onreadystatechange trigger in Firefox 2.0

Posted on 2006-11-23
4
247 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 250 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Javascript: Range object 16 33
How to size popup in jquery mobile 4 60
CSV export single column not inserting comma's in file 11 65
Make icons act like add/minus for qtys 6 43
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

734 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