viralpatel.info

Tutorials

Tutorials

AJAX :: Asynchronous Javascript And XML

AJAX is based on XMLHttpRequest

With this object we can assign actions to occur at specific properties like...

Properties of XMLHttpRequest
  • onreadystatechange
  • readyState
  • responseText
  • responseXML
  • status
  • statusText
Values for readyState
  • 0 = Uninitialized ; 'open' is not yet called
  • 1 = Loading ; 'send' for request is not yer called
  • 2 = Loaded ; 'send' is called, headers & status are available
  • 3 = interactive ; downloading response
  • 4 = Completed ; finished downloading response
responseText
  • Response as Text OR null if readyState < 3
responseXML
  • Response as DOM document object OR null if readyState < 3
status
  • Integer HTTP status code
statusString
  • Status String

Methods of AJAX

Basic Methods
  • open(method, url [,async]) - initializes a new HTTP request -method : GET, POST, PUT, DELETE -url : http url -async : true/false
  • send(body) -Sends HTTP request
  • abort() -Called after 'send' to cancel the request
Header Methods
  • void setRequestHeader(name, value)
  • String getResponseHeader(name)
  • String getAllResponseHeaders()
Enjoy AJAXing !
ViRaL
(www.viralpatel.info)