| 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
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
|
A very simple google search would've landed you here...
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
|
Moving to Html/Javascript forum...
|
 |
Saifuddin Merchant
Ranch Hand
Joined: Feb 08, 2009
Posts: 576
|
|
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 ??
|
 |
 |
|
|
subject: How many times onreadystatechange property of XMLHTTPREQUEST would be get called?
|
|
|