aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes How many times onreadystatechange property of XMLHTTPREQUEST would be get called? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How many times onreadystatechange property of XMLHTTPREQUEST would be get called?" Watch "How many times onreadystatechange property of XMLHTTPREQUEST would be get called?" New topic
Author

How many times onreadystatechange property of XMLHTTPREQUEST would be get called?

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

The following below code is related to AJAX .

can anybody please let me know how many times the function getOutput will be getting called ??




Waiitng for your replies .
Thanks in advance .

Save India From Corruption - Anna Hazare.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9313
    
  17

A very simple google search would've landed you here...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9313
    
  17

Moving to Html/Javascript forum...
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 606

W3schools offers a better explanation on the ready-state-change here.

To answer your question in particular, it cannot be determined. While transitions between states are defined certain states may trigger the on-ready-state function multiple times (e.g. 3: processing request ).

Note - W3schools mentions that "onreadystatechange event is triggered four times, one time for each change in readyState.", but I remember of some place that onreadystatechange could trigger of multiple times, for the same state.

Usually there is no interest in the other states and the only state that is important is readyState==4 and status==200. Using a Javascript library JQuery, Prototype even hide this and give you simple function to work with like Ajax.Load('page', element)


Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
vijin das
Ranch Hand

Joined: Jun 07, 2010
Posts: 129

The onreadystatechange event is triggered every time the readyState changes.

The readyState property holds the status of the XMLHttpRequest and Changes from 0 to 4:

The onreadystatechange event is triggered four times, one time for each change in readyState and which are like ...


0: request not initialized
1: server connection established
2: request received
3: processing request
4: request finished and response is ready

In the onreadystatechange event, we specify what will happen when the server response is ready to be processed.

When readyState is 4 and status is 200, the response is ready:

VIJINDAS
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Thank you very much .

Javaranch has helped me a lot , how can i help this site in back ??
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How many times onreadystatechange property of XMLHTTPREQUEST would be get called?