AJAX Interview Questions and Answers

AJAX stands for Asynchronous JavaScript And XML.It is not a programming language.It allows web pages to be updated asynchronously by exchanging data with a web server.This means that it is possible to update parts of a web page without reloading the whole page.

1) Differentiate between Synchronous and Asynchronous Ajax requests?

Synchronous Ajax requests: In this, the script stops and waits for the server to reply before continuing. In the web application world, one has to happen after the other, i.e. the interaction between the customer and the server is synchronous. Synchronous is not recommended as it blocks/hangs the page until the response is received from the server.

Asynchronous Ajax requests: It handle the reply as and when it comes and allows the page to continue to be processed. Under Asynchronous, if there is any problem in the request it can be modified and recovered. The request doesn’t block the client as the browser is responsive. The user can perform other operations as well.

2) What is XMLHttpRequest object in Ajax?

The XMLHttpRequest objects are used to exchange data with a server. It is an API whose methods transfer between a web browser and a web server. In XHR, it’s not necessary that data have to be in form of XML. It can be JSON or HTML. XHR can be used with protocols other than HTTP. XMLHttpRequest is any developers kit because it has the option to update the page without reloading the entire page. You can request data from the server and also send data to the server in the background.

3) What are the advantages of AJAX?

  1. Quick Response
  2. Bandwidth utilization
  3. The user is not blocked until data is retrieved from the server.
  4. It allows us to send only important data to the server.
  5. It makes the application interactive and faster.

4) What are the disadvantages of AJAX?

  1. Dependent on JavaScript
  2. Security issues
  3. Debugging is difficult

5) What are the real web applications of AJAX currently running in the market?

  1. Twitter
  2. Facebook
  3. Gmail
  4. Youtube

6) What are the technologies used by AJAX?

  1. HTML/XHTML and CSS - These technologies are used for displaying content and style.
  2. DOM - It is used for dynamic display and interaction with data.
  3. XML - It is used for carrying data to and from server
  4. XMLHttpRequest - It is used for asynchronous communication between client and server.
  5. JavaScript - It is used mainly for client-side validation

7) What is JSON in AJAX?

JSON stands for JavaScript Object Notation. In AJAX, it is used to exchange data between a browser and a server. It is easy to understand, and data exchange is faster than XML. It supports array, object, string, number, and values.

8) What is the difference between JavaScript and AJAX?


AJAX is a group of inter-related technologies like JavaScript, XML,HTML,CSS etc JavaScript is an object-based   scripting language.                                   
It sends a request to the server and doesn't wait for the response.It requests the server and waits for the response.
It doesn't reload the page so consumes less bandwidth.It consumes more bandwidth as it reloads the page.


9) What is the purpose of XMLHttpRequest?

  1. It sends data in the background to the server.
  2. It requests data from the server.
  3. It receives data from the server.
  4. It updates data without reloading the page.

10) What are the properties of XMLHttpRequest?

The important properties of the XMLHttpRequest object are given below:

  1. onReadyStateChange - It is called whenever readystate attribute changes.
  2. readyState - It represents the state of the request.
  3. responseText - It returns response as text.
  4. responseXML - It returns response as XML.
  5. status - It returns the status number of a request.
  6. statusText - It returns the details of status.