Ajax interview questions and answers

Which are limitations of AJAX?

- Back functionality can’t work because the dynamic pages won’t register themselves to the browsers cache. Hence the use Iframe will become required.
- The page cannot be bookmarked if it is developed using Ajax.
- If java script is not enabled, Ajax will stop working.
- Because different components of the pages are loaded at different times, response time may be slow.
- Because different components of the pages are loaded at different times it may create confusion for the user.

What is the difference between synchronous postback and asynchronous postback?

The difference between synchronous and asynchronous postback is as follows:

- Asynchronous postback renders only the part of the page which is needed; while, synchronous postback renders the entire page in a postback.
- Asynchronous postback executes only one postback at a time, that is, if you have two buttons doing asynchronous postback, the actions are executed one by one; while, - synchronous postback invoke all the actions at a time.
- Asynchronous postback only changes the update panel that invoke the postback; while, synchronous postback changes the entire page.

Why do we use the XMLHttpRequest object in AJAX?

- Javascript uses the XMLHttpRequest object to manipulate XML and other text data between client and server.
- AJAX applications use the XMLHttpRequest object to avoid the postback of entire page when the browser is communicating with server.
- The XMLHttpRequest object enables a client-side script to execute an HTTP request.
- For this functionality MSXML ActiveX component is used in earlier version of Internet Explorer. While, XMLHttpRequest is used in Internet Explorer 7 and other browsers, such as Mozilla, Firefox.

What are the new features included in the Microsoft AJAX library?

The new features included in the Microsoft AJAX library are as follows:

- Imperative syntax: AJAX library provide simple imperative syntax which is required to create and manage controls.
- Script loader: It is used to retrieve all scripts automatically which are required by one or more client component or control and executes them in the order in which they are received.
- Client data access: It’s used to access client data and display by client data control and client template.
- Client datacontext: It’s used to read and write the permission to data in a database.
- The AdoNetDataContext class - Supports to easily communicate to an ADO.NET Data Services service.

What are the new features of ASP.NET AJAX 4.0?

These features are as follows:

- It enables the application to bind the live data.
- It enables to render the client-side template.
- It enables declarative instantiation of client components.
- It provides observer pattern on JavaScript objects and arrays.
- It provides the facility to invoke ADO.NET data services and data contexts.
- It supports for the DataView control.

How many validation controls are supported in ASP.NET AJAX 4.0?

The following validation controls are supported in ASP.NET AJAX 4.0:

- FilteredTextBoxExtender : This validation is used to apply filtering to a text box.
- MaskedEditExtender and MaskedEditValidator : These validation controls are used to prevent a user to enter only a particular pattern of characters in the TextBox.
- ValidatorCalloutExtender : This validation is used to display a balloon tooltip containing the error message by attaching the ASP.NET validators.
- NoBot : It restricts the input forms automatically to be filled by spam/bot and used to ensure that the user is not a computer machine by the automated Public Turing test.
- PasswordStrengthExtender : It is used to find the strength of the password entered in the text box by checking the different strength related parameters.

What are the differences between AJAX and JavaScript?

The differences between AJAX and JavaScript are given as follows:

- AJAX sends request to the server and will not wait for the response.
- It will allow other operations on the page before it get response of previous request; whereas, JavaScript make a request to the server, will waits for response and will not allow other operation on the page during that time.
- In AJAX, the page will not get refreshed for downloading the whole page while JavaScript manages and controls a Web page after being downloaded.
- By using AJAX we can minimize the overload on the server because the script needs to request once while JavaScript posts the request that updates the script each time.

List the different states of XMLHttpRequest with their description.

The different states of the XMLHttpRequest object are as follows:

1) Uninitialized : It is the state in which the object has not been initialized.
2) Open: It is the state when the object has been created but the send function is not invoked.
3) Sent: It is the state when the send function is invoked but the status and headers are not available.
4) Receiving: It is the state when the data is received by the process.
5) Loaded: It is the state when the procedure is completed and the data is available.

Describe the AccordionExtender control.

- The AccordionExtender control is almost same as the CollapsiblePanelExtender control.
- It enables the grouping of multiple collapsible panels in a single control.
- It also manages the collapsed and expanded state of every panel and one panel will expand at a time.
- Using AccordionExtender control we can’t expand two or more panels at a time.

However, we can click the header templates of particular panel to display the hidden contents.

By default, one panel is always expanded in theAccordionExtender.

How do I provide internationalized AJAX interactions?

To provide internationalized AJAX components you need to do the following:

Set the charset of a page to an encoding which is provided by the target languages. The following meta declaration in your HTML/JSP page is used to set the content type:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

In the page JavaScript ensure that the encoding of any parameters sent to the server is done. To achieve this JavaScript has the escape() function which will give Unicode escape strings containing localized text in hexadecimal format.

In the server side component set the character encoding using the HttpServletRequest.setCharacterEncoding() method. Before accessing the localized parameter with HttpServletRequest.getParameter() call. In the case of UTF this will be request.setCharactherEncoding("UTF-8");.

A server-side component returning AJAX responses requires to set the encoding of the response to the similar encoding used in the page.

response.getWriter().write(" <response>Not valid </response>");
1 2

AJAX and problem it solve
Ajax: It is a short for Asynchronous JavaScript and XML. It solves the problem of unnecessary data transfers and allows asynchronous processing and avoids unnecessary processing to be done by server.
What are the benefits of AJAX over Java applet?
What are the benefits of AJAX over Java applet? - The following are the benefits of AJAX over Java applet:
What is the disadvantage of AJAX?
Data is stored at the client side so crucial and confidential data should not be stored to avoid any kind of security issues
Post your comment
Discussion Board
Ajax interview
Thanking for sharing these questions on Ajax. It is quite helpful
vinod 05-19-2013
Ajax Interview Questions
Great list of questions!.

Find out some more questions here i found http://codershelpdesk.com/2012/06/16/ajax-interview-questions-part-i/
Sunny 06-16-2012
Ajax interview questions and answers.
How to control how long an Ajax request may last?

We can use the triggers of Script Manager or the property of AsyncPostBackTimeout to control the web page and the request which is being made to the server. A timed out request will be published when the page no longer remains available for debug. Example Code:

<asp:ScriptManager id="ScriptManager1" runat="server" AsyncPostBackTimeout="9000"/>

[Note: the values here are in seconds]

What is the ASP.NET Ajax Framework? What versions have been released so far?

ASP.NET Ajax Framework is a free framework that gets implemented for web applications. This provides lot of tools to create easy to use, efficient and interactive web applications that work on all the platforms and browsers. This framework includes reusable Ajax controls, access remote service methods, data accessing methods etc. The version which has been released till now is as follows:-

1 - ASP.NET Ajax Framework 1.0 (earlier release to this was called the Atlas)
2 - ASP.NET Ajax Framework 1.0 for ASP.NET 2.0
Rohit Sharma 12-11-2011
Ajax interview questions and answers.
What are the properties of the XmlHttpRequest object?
XmlHttpRequest is an API, used in scripting language such as JavaScript. It sends HTTP and HTTPS requests directly to the server and load the server response directly in the script. The properties of it are as follows:

onreadystatechange property: it is a special property that processes the responses from the server. Example code:

ajaxRequest.onreadystatechange = function()

{// code}

readystate property: status of server’s response is stored. Example code:

ajaxRequest.onreadystatechange = function()

{if(ajaxRequest.readyState == 4)

{// Code to get the data from server}


responsetext property: retrieval of the server response can be seen by this property. Example code:

ajaxRequest.onreadystatechange = function()

{if(ajaxRequest.readyState == 4)

{document.myForm.time.value = ajaxRequest.responseText;}

Rohit Sharma 12-11-2011
Ajax interview questions and answers.
How do I create a thread to do AJAX polling?
JavaScript as an integral part of AJAX, it works when an event happens or an action is being taken such as page load, mouse click etc. A timer can be set to take the function name and time as arguments. A thread will be created, the moment the function checkforMessage() will be called. The thread will continue to execute and the result of it will be pooled in the database. Example code:

Function checkForMessage()
// start AJAX interaction with processCallback as the callback function
// callback for the request
function processCallback()
// do post processing
setTimeout(“checkForMessage()”, 10000);

How many types of triggers are there in update panel?
Triggers are the stored procedures used in the database. There are 2 types of triggers in update panel, which are as follows:

1. PostBackTrigger : This trigger is the internal trigger of the update control. It doesn’t work asynchronously. It short circuits the control to do synchronous post back. For example Update control panel

2. AsyncPostBackTrigger : This trigger is a control, that is external to update control. It works synchronously. It wires up the control to do asynchronous post back.
Rohit Sharma 12-11-2011
Ajax interview questions and answers.
What are ASP.NET Ajax Extensions?
ASP.NET Ajax is a set of extensions developed by Microsoft in ASP.NET, to provide the functionality of AJAX. The extension provides configuration for localization and adaption without the use of Ajax. These are set of Ajax based controls that work in ASP.NET applications. It consists of the libraries to provide more support and functionality to applications. Few extension examples are:

ASP.NET Ajax Extensions 1.0 -> For ASP.NET 2.0

ASP.NET Ajax Extensions 3.5 -> For ASP.NET 3.5

What is the use of UpdatePanel Control?
UpdatePanel control is a server control that controls the updates of the web page without reloading, in ASP.NET. It can be done through a mechanism called as asynchronous postback. In this process, HTML of the page is sent by the server asynchronously through Ajax request. Triggers are used to control the content of it and allow refresh content to be loaded all the time. The example below shows that the content of the Update control is re-rendered every time the button is clicked.

<asp:Button ID="Button1" runat="server" Text="Refresh" />

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
<span><%= DateTime.Now %></span>
Rohit Sharma 12-11-2011
Ajax interview questions and answers.
How to handle concurrent requests in Ajax?

An array of XMLHttpRequest is used to create a new XMLHttpRequest that can be executed each time the concurrent request is being made. JavaScript allows more than one AJAX request to be executed at once. In this abstracted JavaScript object is being used in the form of XMLHttpRequest object. This object is named as AJAXInteraction. The function is shown below:

function AJAXInteraction(url, callback)

{ var req = init();
req.onreadystatechange = processRequest;

function init() {
if (window.XMLHttpRequest)

{ return new XMLHttpRequest(); }

else if (window.ActiveXObject)

{ return new ActiveXObject("Microsoft.XMLHTTP"); }


What is Dojo?

Dojo is a third-party JavaScript toolkit. It is used to create rich featured applications. It helps in saving time, increase the performance and deliver good result for the business. Dojo is an open source toolkit and also referred as “unified toolkit”. It is a DHTML toolkit which is good in solving difficult problems and it also helps developers to build easy to use web applications.
Rohit Sharma 12-11-2011
Ajax interview questions and answers
Differentiate between proxied and proxyless calls.
- Proxied calls - These are made through stub objects that mimic your PHP classes on the JavaScript side.
- Proxyless calls - These are made using utility javascript functions like HTML_AJAX.replace() and HTML_AJAX.append().

Ajax is just another name for XMLHttpRequest - Is it true?
- No. XMLHttpRequest is just a part of the Ajax equation.
Harshvardhan 12-6-2011
Ajax interview questions and answers
Is AJAX code cross browser compatible?
No, not absolutely. Most of the browsers offer a native XMLHttpRequest JavaScript object, while IE needs to get it as an ActiveX object.

Does Ajax work on web servers other than IIS?
Yes, it does. Ajax is independent of the web server on which web application is hosted.

What is the full form of AJAX?
AJAX - Asynchronous JavaScript and XML.
Prateek 12-6-2011
Ajax interview questions and answers
Explain Comet.
Comet - applications where the server keeps pushing - or streaming - data to the client rather than the browser polling the server for fresh content.

What advantages does Ajax provide to Internet applications?
It makes them smaller, faster and more user friendly.

Explain AJAX polling.
Process of retrieving data from a server to obtain near-live data regularly.
Rachna 12-6-2011