Register Login

Ajax Interview Questions and Answers for Experienced

Updated Feb 12, 2019

What is Ajax & What does Ajax stand for?

AJAX stands for Asynchronous JavaScript and XML. It is used to create better web applications using XHTML for developing the main content and CSS for styling. It also operates on the DOM (Document Object Model) and Javascript for making the web apps and pages dynamic.

What are all the features of Ajax?

The features of AJAX are described below:

  • It is a web browser technology that is not dependent on the web server.
  • It enhances the speed of the website.
  • It supports data view control.
  • It is used to make responsive user interfaces.
  • It can be used to load only a part of the website that is required, not the entire site.
  • Live data binding is supported.

What are the advantages and disadvantages of using ajax?

The advantages of AJAX are:

  • AJAX does not depend on server technology.
  • Faster and interactive web pages can be developed easily.
  • The applications based on AJAX use less server bandwidth.
  • Form validation is easier to implement using AJAX.

The disadvantages of AJAX are:

  • It does not run in every browser.
  • Some browsers like Google can’t index AJAX.
  • Anyone can view the source code making it less secure.
  • Server information cannot be accessed.

What is Ajax loading?

In AJAX loading, the server data is obtained without reloading the entire web page. This makes web page faster to operate, especially those pages that have heavy images and plug-ins.

How to pass data from javascript to php using Ajax?

The steps to pass data to php using javascript :

  • Create a form having a submit button.
  • Use javascript to obtain input values.
  • Develop an AJAX method to send the information to the php
  • Receive the information using a php handler script.

How to run Ajax on localhost?

AJAX can be run on localhost using Apache server.

What is the difference between Synchronous and Asynchronous Ajax requests?

Synchronous requests

Asynchronous requests

It blocks the browser’s javascript engine until the operation is completed.

It does not block the browser’s javascript engine until the operation is completed.

The browser becomes unresponsive and the user cannot do other operations.

The browser is responsive and the user can do other operations.

The entire web page is refreshed during the request

The entire web page is not refreshed during the request, the user gets a response from the AJAX engine.

How Ajax is Asynchronous?

AJAX is asynchronous as it updates the web pages without reloading the entire web page. Only a portion of the web page is reloaded. It passes only the information to and fro from the server.

What is XHR in Ajax?

XHR (XML Http Request) is an API in AJAX that is used to transfer and operate XML data from a web server using HTTP requests. It is useful for creating a communication bridge between the client side and the server side.

What is the role of ScriptManager in Ajax?

In AJAX, the client side scripts are handled using the Script Manager. It is used to handle all the ASP.Net resources on the web pages. Wherever AJAX is to include the libraries, the script manager is used.

What are some most common AJAX frameworks?

The most common AJAX frameworks are Angular JS, Backbone.js, jQuery, ASP.NET AJAX, Google Web Toolkit and Echo.

Why AJAX won't work in browsers like IE, Firefox and Safari?

AJAX does not work in browsers such as IE, Safari, and Firefox as they do not support XHR (XML HTTP Request). Therefore, the communication channel between the client side and the server side cannot be developed.

What is the difference between SPA and AJAX?

SPA

AJAX

It is a single page application that runs within a single web page

It is used by the client to communicate with the server

The code written here is used to develop a standalone application.

The code written here is used to manage the back end communications of the web page.

As it consists of a single page, not a lot of data is transferred between web pages.

Data gets transfers over multiple web pages smoothly.

What is reverse Ajax?

Reverse AJAX is a methodology that is used to transfer information between a web server and a browser. Here, data is sent asynchronously from the server to the client.

How to make AJAX calls secure?

The AJAX calls can be made secure using the following steps:

  • POST can be used to keep the important details in the URL.
  • Using the CSRF (Cross Site Request Forgery) token, all the requests can be checked. This token has to be made on the server and has to be set as metadata, to the web page where the JS will be loaded.
  • Send the AJAX calls along with this token while checking that the tokens match before any processing is performed.

How to return a string from an Ajax call?

A string can be obtained from an AJAX call using a promise method and a success callback.

How to call a multiple URL in one Ajax callback?

Multiple URL calls can be made in one AJAX callback using the jQuery AJAX method. The following code can be used:

var ajax1 = $.ajax({

  dataType: "json",

  url: "url1",

  success: function(result) {}                    

});

var ajax2 = $.ajax({

  dataType: "json",

  url: "url1",

  success: function(result) {} 

});

$.when( ajax1 , ajax2  ).done(function( a1, a2 ) {

   var data = a1[0] + a2[0]; // a1[0] = "Got", a2[0] = " Success"

   if ( /Got Success/.test( data ) ) {

      alert( "Successfully responded to all calls." );

   }

});

What is XMLHttpRequest object in Ajax?

The XHR object in AJAX is used to transfer data between the client side and the server side. Therefore, some parts of the web page can be modified and updated. It is not necessary to reload the entire page. The syntax to create an XHR object is:

var xhrobject1 = new XMLHttpRequest();

What are the some best alternatives to AJAX?

Some of the most popular alternatives to AJAX are Ruby on Rails, XAML, Flash and SVG.

When should you use 'HEAD' and 'POST' in your AJAX request?

HEAD requests are similar to GET request but is used to obtain the response headers from the server. The information about the web server can be obtained using HEAD. Meta information embedded within HTTP headers can be accessed using this.

POST is used to obtain data from the server. It can send data and the request together. Any type of data can be sent with the request.        


×