What is AJAX?

AJAX = Asynchronous JavaScript And XML.

AJAX is not a programming language.

AJAX just uses a combination of:

  • A browser built-in XMLHttpRequest object (to request data from a web server)
  • JavaScript and HTML DOM (to display or use the data)

AJAX can be used for interactive communication with an PHP, .ASP, Databases, XML file,

Here i am showing use of AJAX for interactive communication with an XML file.

Inside my .xml

Inside xml file we use few tags (you can make your own tags) and i will call these tags value using AJAX (a part of Javascript) which will show my friend list and their details (For Example).

Inside .js we used few methods of AJAX :

new XMLHttpRequest()

  • Creates a new XMLHttpRequest object


  • Returns specific header information

open(method, url, async)

  • Specifies the request

Also we used few property of AJAX :


  • Defines a function to be called when the readyState property changes


  • Holds the status of the XMLHttpRequest.
  1. 0= request not initialized
  2. 1= server connection established
  3. 2= request received
  4. 3= processing request
  5. 4= request finished and response is ready


  • Returns the response data as a string


  • Returns the response data as XML data


  • Returns the status-number of a request
  1. 200= "OK"
  2. 403= "Forbidden"
  3. 404= "Not Found"

For a complete list go to the Http Messages Reference

Why use AJAX?

AJAX allows web pages to be updated asynchronously by exchanging 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.

For more query visit w3schools AJAX

Hope this will help you <3