• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 .
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A very simple google search would've landed you here...
 
Ankit Garg
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to Html/Javascript forum...
 
Ranch Hand
Posts: 608
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)
 
Ranch Hand
Posts: 129
Firefox Browser Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much .

Javaranch has helped me a lot , how can i help this site in back ??
 
reply
    Bookmark Topic Watch Topic
  • New Topic