Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

AJAX Interview Questions and Answers

What is Ajax and how does it work?
The AJAX stands for “Asynchronous JavaScript and XML” and AJAX is a technique to creating Interactive Web Applications and allows us to send and receive data asynchronously without refreshing the web page.

The XMLHttpRequest object is part of a technology called AJAX.

AJAX is very faster and easy, we can implement AJAX in a meaningful manner.

It is a group of related technologies looks like,
a)     HTML/XHTML and CSS
b)     DOM
c)      XML or JSON
d)     XMLHttpRequest
e)     JavaScript

The AJAX was popular in 2005 by Google, with Google Suggest.

Syntax- The parameters specify one or more name/value pairs for the AJAX request.
$.ajax({name:value, name:value, ... })


Why do you use Ajax?
The AJAX stands for “Asynchronous JavaScript and XML” and AJAX is a technique to creating interactive web applications and allows us to send and receive data asynchronously without refreshing the web page.

The AJAX technology used by
a)     Google,
b)     Facebook,
c)      Twitter etc.

Is Ajax still in use?
Yes! AJAX (Asynchronous JavaScript and XML) is used all the time in web pages. It is still the primary way that JavaScript in a web page makes an in-page request to a server.

Is Ajax considered a programming language?
The AJAX (Asynchronous JavaScript and XML) is not a programming language or a tool, but a concept.
The AJAXis a client-side script that communicates to and from a server/database without the need for a post-back or a complete page refresh.
Which are the two methods used for cross domain AJAX calls?
There are two methods used to transfer data between the two more security domains:
1)      CORS  (Cross Origin Resource Sharing) - It works with the HTTP web browsers
2)      JSONP( JSON with Padding) - It works with the HTTP GET and on legacy browsers

What are the technologies used by AJAX?
1)      HTML/XHTML and CSS
2)      DOM
3)      XML
4)      XMLHttpRequest
5)      JavaScript

What is JSON in AJAX?
The JSON (Asynchronous JavaScript and XML) is abbreviated as JavaScript Object Notation.

The JSON (Asynchronous JavaScript and XML) is a safe and reliable data interchange format in JavaScript, which is easy to understand for both users and machines.

How to handle multiple Async Ajax Requests?
We well know $.Ajax () is call asynchronously by nature but problem is that multiple (>1000 calls) Async AJAX calls on a single page.

$(function() {
  $.ajax({
      type: "GET",
      url: "https://api.github.com/users/anilsingh581",
      success:function (data) { alert(data); }
  });

  $.ajax({
      type: "GET",
      url: "https://api.github.com/users/anilsingh5812",
      success:function (data) { alert(data); }
  });

  $.ajax({
      type: "GET",
      url: "https://api.github.com/users/anilsingh5813",
      success:function (data) { alert(data); }
  });
});


But its display error:  err_insufficient_resources when using chrome any hints.

The solution of above problem is:  $.when () method
//The multiple AJAX requests by using $.when()
$.when(
  $.ajax("https://api.github.com/users/anilsingh581"),
  $.ajax("https://api.github.com/users/anilsingh582"),
  $.ajax("https://api.github.com/users/anilsingh583"),
  $.ajax("https://api.github.com/users/anilsingh584")
  )
  .done(function(data1, data2, data3, data4) {
      //All AJAX requests are finished.
      alert(data1)
      alert(data2)
      alert(data3)
      alert(data4)
  });


OR
$.when($.ajax("/pageurl1.aspx"), $.ajax("/pageurl2.aspx"), $.ajax("/pageurl3.aspx")).then(mySuccess, myFailure);

varmySuccess = function(result) {
  console.log(result);
}

varmyFailure = function(result) {
  console.log(result);
}

What are the Advantages and Disadvantages of AJAX?
The AJAX stands for “Asynchronous JavaScript and XML” and AJAX is a technique to creating interactive web applications and allows us to send and receive data asynchronously without refreshing the web page.

The XMLHttpRequest object is part of a technology called AJAX.
AJAX is very faster and easy, we can implement AJAX in a meaningful manner.

Advantages:-
1)      Minimal Data Transfer
2)      An asynchronous call by XMLHttpRequest and it is hold and wait process.
3)      Reduce the traffic travels between the client and the server and the response time is faster so increases performance and speed.
4)      Better responsive and interactivity and faster page renders and improved response times.
5)      Supports almost all modern browsers.
6)      Easy Navigation.
7)      Open source JavaScript libraries available for AJAX support like JQuery, etc.

Disadvantages:-
1.      Insecure and increment the load on web server.
2.      All files are downloaded at client-side.
3.      Browser compatibility issues accrued.
4.      The search engines are not crawling AJAX generated content that means Google can’t index AJAX pages.
5.      AJAX does not play well in encrypted environments.
6.      The server information can't be accessed using AJAX.
7.      Data of all requests is URL encoded and causes increases the size of the request.
8.      ActiveX requests are enabled only in Internet Explorer and newer latest browser.

How does an AJAX call work?
Example for calling “Synchronous” and “Asynchronous” Requests -
//AJAX Synchronous and Asynchronous Requests
//#REGION NAMESPACE
vardemo = demo|| {};

Share the post

AJAX Interview Questions and Answers

×

Subscribe to Angular 2 Javascript Asp.net C# Sql Server Knockoutjs Angularjs Kendo Ui Html 5 Web Api Wpf Wcf Etc.

Get updates delivered right to your inbox!

Thank you for your subscription

×