Ajax has made it easier to send and retrieve data from a server asynchronously without interfering with the existing page’s display and functionality.
Ajax not a programming language and it requires a built-in browser with the XMLHttpRequest object, which requests data from the server. It also uses JavaScript and HTML DOM to display the data.
Ajax response is the server response, and Ajax.Response
is the object passed as the first argument of all Ajax requests callbacks.
status
Type: Number.
The server sends the HTTP status code.
statusText
Type: String.
Status text sent by sever.
readyState
Type: Number. The current state of the request.
The numbers are on the left side and state on the right side.
0 => Uninitialized
1 => Loading
2 => Loaded
3 => Interactive
4 => Complete
responseText
Type: String. Response sent refers to the text body.
responseXML
Type: document Object. Response of body that comprises of XML. This only works if the request is set to XML.
responseJSON
Type: Object, Array. Response of body that comprises of JSON. This only works if the request is set to JSON.
headerJSON
Type: Object, Array.
X-JSON (if present) sends auto-evaluated content. It is used to transfer little pieces of data.
request
Type: Object. The request object.
transport
Type: Object. Refers to the xmlHttpRequest
object itself.
getHeader(name)
Type: String. This method returns the value of present header (if requested); otherwise, null.
getAllHeaders()
Type: String. This method returns a string. This contains all headers as a string.
getResponseHeader(name)
Type: String. This method returns the value of the present header (if requested and if present); otherwise, it throws an error.
getAllResponseHeaders()
Type: String. This method returns a string and contains all headers as a string; otherwise, it throws an error otherwise.
Free Resources