Image

AJAX XMLHttpRequest readyState

The XMLHttpRequest object can be used to exchange data with a web server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page.

When XMLHttpRequest object make a request to the server it goes through process of cycle till it get response.XMLHttpRequest is responsible for request/readyState using onreadystatechange property which triggers or fires a event as readyState changes.

XMLHttpRequest object has various properties like

  • onreadystatechange
  • readyState
  • responseText
  • responseXML
  • status
  • statusText

Let's check it out XMLHttpRequest object properties in detailed way.

Property Description
onreadystatechange Defines a function to be called when the readyState property changes
readyState Holds the status of the XMLHttpRequest.
0: request not initialized
1: server connection established
2: request received
3: processing request
4: request finished and response is ready
responseText Returns the response data as a string
responseXML Returns the response data as XML data
status Returns the status-number of a request
200: "OK"
403: "Forbidden"
404: "Not Found"
statusText Returns the status-text (e.g. "OK" or "Not Found")

Categories: Java Script Tags: #JavaScript,

Newsletter Subcribe

Receive updates and latest news direct from our team. Simply enter your email.