AJAX - readyState Ajax status code

the readystate property :--

the ajax readystate property defines the current state of the xmlhttprequest object.

the xmlhttprequest object cab be in several states.using readystate property retrieves the current state of the request operation.

it's return value type is integer.

the ajax readystate syntax :


here are possible values for the readystate property.

state valuedescription
the readystate property holds the status of the xmlhttprequest.value can change from 0 to 4 :
uninitialized (0)the object has been created, but not initialized.
loading (1)a open() method has been invoked,but send method has not been called.
loaded (2)the send method has been called. no data is available yet.
interactive (3)some data has been received however, neither responsetext nor responsebody is available.
complete (4)all the data has beeb received.

AJAX status property

the ajax status property returns the http status code.

the return value type is integer.

        var  status   =  new xmlhttprequest().status;

some long integer status value is a standard http status code as described in table.

101switching protocols
404not found

the statustext property

the statustext property returns the http status text

the return value type is string .

var status   =  new xmlhttprequest().statustext;