XMLHttpRequest Object readyState property ~ Ajax Training, Learn Ajax Video Tutorials Online, Ajax Examples
Ajax Training, Learn Ajax Video Tutorials Online, Ajax Examples: XMLHttpRequest Object readyState property

XMLHttpRequest Object readyState property

Now we've been introduced to XMLHttpRequest object, their are two properties you should get to know this object and object supports. first is the readyState property of XMLHttpRequest object. the ready state property tells you what's going on XMLHttpRequest object as it is downloading data .
we will be using this ready state property and the ajax enabled web application since you can see hear index.html example we have XMLHttpRequest object. readyState propery, which is the value 4.
So before continuing what is that, take a look at possible values of XMLHttpRequest object 's readySstate property.

the possible values of readyState property are:

0 - Uninitialized
zero means XMLHttpRequest object hasnot been initialized and not ready for been used. Not ready for work and so if the readystate property is zero and you are not going to work out XMLHttpRequest object and hence it is properly initialized.

1 - Loading
one means xmlHttpRequest object is loading the data that you have requested from the server.

2 - Loaded
two means your data has been loaded the requested data that if you acquired of the server that is been loaded and its not yet complete but it been loaded the processing almost has finished

3 - Interactive
Three means that the XMLHttpRequest object it is so called in interactive state which means that the data has been downloaded by the which still you can interact with it and ask it what s type of the readystate property is. So the interactive state means the data has not yet been downloaded it is in processing in downloading so you can interact with XMLHttpRequest object

4 - Complete
Four means the download is complete and we remembered that ajax is for the asynchronous javascript and xml. Asynchronized part means that we are going to use XMLHttpRequest object to ask server send data to us and we are going to wait untill that data is complete we are not pause the browser so this is the way you check data request is complete in XMLHttpRequest object readyState property and when the property value holds for 4 that means asynchronous download of your data is complete

so that introduces the readyState property XMLHttpRequest object and you just see the following javascript code :

function doThis() {
if (request.readyState == 4) {
// do something with the response
}
}

Related Posts by Categories

2 comments:

Ilyas said...

how many types of ready states in ajax?

Radha said...

5 readyStates

0 = uninitialized

1 = loading

2 = loaded

3 = interactive

4 = complete

Useful Links on Adobe Flex

Your Ad Here

Latest Books on Adobe Flex