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
}
}
2 comments:
how many types of ready states in ajax?
5 readyStates
0 = uninitialized
1 = loading
2 = loaded
3 = interactive
4 = complete
Post a Comment