: +91-9350865940
Testimonials
Thank you Dass infotech for the outstanding service and support you provide my business. I very much appreciate the high level of programming skills and the friendly and approachable manner of your staff. Nothing is ever a problem. I look forward to working with you well into the future!
Dass, Owner/Manager

Ajax interview Questions and Answers
Q. What's AJAX ?

A. AJAX (Asynchronous JavaScript and XML) is a newly coined term for two powerful browser features that have been around for years, but were overlooked by many web developers until recently when applications such as Gmail, Google Suggest, and Google Maps hit the streets.

 
Q. Who’s Using Ajax ?
A. Google is making a huge investment in developing the Ajax approach. All of the major products Google has introduced over the last year — Orkut, Gmail, the latest beta version of Google Groups, Google Suggest, and Google Maps — are Ajax applications. (For more on the technical nuts and bolts of these Ajax implementations, check out these excellent analyses of Gmail, Google Suggest, and Google Maps.) Others are following suit: many of the features that people love in Flickr depend on Ajax, and Amazon’s A9.com search engine applies similar techniques. These projects demonstrate that Ajax is not only technically sound, but also practical for real-world applications. This isn’t another technology that only works in a laboratory. And Ajax applications can be any size, from the very simple, single-function Google Suggest to the very complex and sophisticated Google Maps. At Adaptive Path, we’ve been doing our own work with Ajax over the last several months, and we’re realizing we’ve only scratched the surface of the rich interaction and responsiveness that Ajax applications can provide. Ajax is an important development for Web applications, and its importance is only going to grow. And because there are so many developers out there who already know how to use these technologies, we expect to see many more organizations following Google’s lead in reaping the competitive advantage Ajax provides. Moving Forward
 
Q. Should I consider AJAX?
A. AJAX definitely has the buzz right now, but it might not be the right thing for you. AJAX is limited to the latest browsers, exposes browser compatibility issues, and requires new skill-sets for many. There is a good blog entry by Alex Bosworth on AJAX Mistakes which is a good read before you jump full force into AJAX. On the other hand you can achieve highly interactive rich web applications that are responsive and appear really fast. While it is debatable as to whether an AJAX based application is really faster, the user feels a sense of immediacy because they are given active feedback while data is exchanged in the background. If you are an early adopter and can handle the browser compatibility issues, and are willing to learn some more skills, then AJAX is for you. It may be prudent to start off AJAX-ifying a small portion or component of your application first. We all love technology, but just remember the purpose of AJAX is to enhance your user's experience and not hinder it.
 
Q. Does AJAX work with Java?
A. Absolutely. Java is a great fit for AJAX! You can use Java Enterprise Edition servers to generate AJAX client pages and to serve incoming AJAX requests, manage server side state for AJAX clients, and connect AJAX clients to your enterprise resources. The JavaServer Faces component model is a great fit for defining and using AJAX components.
 
Q. Won't my server-side framework provide me with AJAX?
A. You may be benefiting from AJAX already. Many existing Java based frameworks already have some level of AJAX interactions and new frameworks and component libraries are being developed to provide better AJAX support. I won't list all the Java frameworks that use AJAX here, out of fear of missing someone, but you can find a good list at www.ajaxpatterns.org/Java_Ajax_Frameworks. If you have not chosen a framework yet it is recommended you consider using JavaServer Faces or a JavaServer Faces based framework. JavaServer Faces components can be created and used to abstract many of the details of generating JavaScript, AJAX interactions, and DHTML processing and thus enable simple AJAX used by JSF application developer and as plug-ins in JSF compatible IDE's, such as Sun Java Studio Creator.
 
Q. Where should I start?
Assuming the framework you are using does not suffice your use cases and you would like to develop your own AJAX components or functionality I suggest you start with the article Asynchronous JavaScript Technology and XML (AJAX) With Java 2 Platform, Enterprise Edition. If you would like to see a very basic example that includes source code you can check out the tech tip Using AJAX with Java Technology. For a more complete list of AJAX resources the Blueprints AJAX home page. Next, I would recommend spending some time investigating AJAX libraries and frameworks. If you choose to write your own AJAX clients-side script you are much better off not re-inventing the wheel. AJAX in Action by Dave Crane and Eric Pascarello with Darren James is good resource. This book is helpful for the Java developer in that in contains an appendix for learning JavaScript for the Java developer.
 
Q. Did Adaptive Path invent Ajax? Did Google? Did Adaptive Path help build Google’s Ajax applications?
A. Neither Adaptive Path nor Google invented Ajax. Google’s recent products are simply the highest-profile examples of Ajax applications. Adaptive Path was not involved in the development of Google’s Ajax applications, but we have been doing Ajax work for some of our other clients.
 
Q. Is it possible to set session variables from javascript?
A. It's not possible to set any session variables directly from javascript as it is purely a client side technology. You can use AJAX though to asyncronously...
 
Q. When should I use an Java applet instead of AJAX?
A. Applets provide a rich experience on the client side and there are many things they can do that an AJAX application cannot do, such as custom data streaming, graphic manipulation, threading, and advanced GUIs. While DHTML with the use of AJAX has been able to push the boundaries on what you can do on the client, there are some things that it just cannot do. The reason AJAX is so popular is that it only requires functionality built into the browser (namely DHTML and AJAX capabilities). The user does not need to download and/or configure plugins. It is easy to incrementally update functionality and know that that functionality will readily available, and there are not any complicated deployment issues. That said, AJAX-based functionality does need to take browser differences into consideration. This is why we recommend using a JavaScript library such as Dojo which abstracts browser differences. So the "bottom line" is: If you are creating advanced UIs where you need more advanced features on the client where you want UI accuracy down to the pixel, to do complex computations on the client, use specialized networking techniques, and where you know that the applet plugin is available for your target audience, applets are the way to go. AJAX/DHTML works well for applications where you know the users are using the latest generation of browsers, where DHTML/AJAX "good enough" for you, and where your developers have JavaScript/DHTML/AJAX skills. Many amazing things can be done with AJAX/DHTML but there are limitations. AJAX and applets can be used together in the same UIs with AJAX providing the basic structure and applets providing more advanced functionality. The Java can communicate to JavaScript using the Live-Connect APIs. The question should not be should framed as do I use AJAX or applets, but rather which technology makes the best sense for what you are doing. AJAX and applets do not have to be mutually exclusive.
 
Q. What kinds of applications is Ajax best suited for?
A. We don’t know yet. Because this is a relatively new approach, our understanding of where Ajax can best be applied is still in its infancy. Sometimes the traditional web application model is the most appropriate solution to a problem.
 
Q. Does this mean Adaptive Path is anti-Flash?
A. Not at all. Macromedia is an Adaptive Path client, and we’ve long been supporters of Flash technology. As Ajax matures, we expect that sometimes Ajax will be the better solution to a particular problem, and sometimes Flash will be the better solution. We’re also interested in exploring ways the technologies can be mixed (as in the case of Flickr, which uses both).
 
Q. What is the XMLHttpRequest object?
A. It offers a non-blocking way for JavaScript to communicate back to the web server to update only part of the web page.
 
Q. Does Ajax have significant accessibility or browser compatibility limitations? Do Ajax applications break the back button? Is Ajax compatible with REST? Are there security considerations with Ajax development? Can Ajax applications be made to work for users who have JavaScript turned off?
A. The answer to all of these questions is “maybe”. Many developers are already working on ways to address these concerns. We think there’s more work to be done to determine all the limitations of Ajax, and we expect the Ajax development community to uncover more issues like these along the way.
 
Q.How do I access data from other domains to create a mashup with Java?
A. From your JavaScript clients you can access data in other domains if the return data is provide in JSON format. In essence you can create a JavaScript client that runs operates using data from a different server. This technique is know as JSON with Padding or JSONP. There are questions as to whether this method is secure as you are retrieving data from outside your domain and allowing it to be excuted in the context of your domain. Not all data from third parties is accessible as JSON and in some cases you may want an extra level of protection. With Java you can provide a proxy to third party services using a web component such as a servlet. This proxy can manage the communication with a third party service and provide the data to your clients in a format of your choosing. You can also cache data at your proxy and reduce trips to service. For more on using a Java proxy to create mashups see The XmlHttpProxy Client for Java.
 
Q. Does Java have support for Comet style server-side push?
A. Current AJAX applications use polling to communicate changes data between the server and client. Some applications, such as chat applications, stock tickers, or score boards require more immediate notifications of updates to the client. Comet is an event based low latency server side push for AJAX applications. Comet communication keeps one of the two connections available to the browser open to continously communicate events from the server to the client. A Java based solution for Comet is being developed for Glassfish on top of the Grizzly HTTP connector. See Enabling Grizzly by Jean-Francois Arcand for more details.
 
Q. How do I create a thread to do AJAX polling?
A. JavaScript does not have threads. JavaScript functions are called when an event happens in a page such as the page is loaded, a mouse click, or a form element gains focus. You can create a timer using the setTimeout which takes a function name and time in milliseconds as arguments. You can then loop by calling the same function as can be seen in the JavaScript example below. 
function checkForMessage() {
// start AJAX interaction with processCallback as the callback function
}
// callback for the request
function processCallback() {
// do post processing
setTimeout("checkForMessage()", 10000);

Notice that the checkForMessage will continue to loop indefinitely. You may want to vary the increment the interval based on activity in the page or your use cases. You may also choose to have logic that would break out of the loop based on some AJAX response processing condition.
 
Q. What kinds of applications is Ajax best suited for?
A.Ajax is a set of client side technologies that allows asynchronous communication between client and web server. In synchronous communication, complete round trip happens with each request/response action event when small data of the page to be refreshed. Ajax has solved this problem of posting entire information every time through asynchronous communication. This increases the speed, functionality, responsiveness, and usability. This technology helps in loading the content behind the scene which will not affect the front side of the language. XmlHttpRequest is the basic fundamental behind Ajax. This allows browser to communicate with server without making post backs.
 
Q. Explain limitations of Ajax.
A. Limitations of Ajax are as follows :
  • Back functionality cannot work because the dynamic pages don't register themselves to the browsers history engine. Hence the need of Iframe becomes essential.
  • The page cannot be bookmarked if implemented using Ajax.
  • If java script is disabled , Ajax will not work
  • 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.
 
Q.What is the role of Script Manager in Ajax?
A. Script Manager, as the name suggests is used to manage the client side script of Ajax. Since Ajax uses Java Script, there needs to be a mediator to manage this script and restrict a particular version to a browser. A Script manager is present on every page where Ajax is used to enable the Ajax Libraries. These Libraries in turn helps to implement the core Functionality of Ajax: Partial rendering.
 
Q. List out differences between AJAX and JavaScript.
A.Ajax is Asynchronous Java Script and XML. Here on sending request to the server, one needn't wait for the response. Other operations on the page can be carried out. Hence, Asynchronous. On the other hand, Java script sends an HTTPRequest to the server and waits for the XML response.
E.g. populating State field. Using JavaScript we need to use the "Onchnage" event where as using ajax, the request is just sent to populate the state list. Other operations can be carried out on the page. 
Ajax is a part of Java Script programming. Java Script is used to manage and control a web page once downloaded. Ajax does not need to wait for the whole page to download. Use of Ajax can reduce connections to the server since the script has to be requested once.
 
Q.Describe how to create AJAX objects.
A. Ajax Objects can be created by the following syntax:
Var ajax= New ajaxObject('page path'). 
Here page path is the URL you want the Object to call. The URL must be of the same domain as the webpage.
 
Q.What is JSON?
A. JSON is a very lightweight data format based on a subset of the JavaScript syntax, namely array and object literals. JSON allows communicating with server in a standard way. JSON is used as communication notation instead of XML.JSON is a safe and reliable data interchange format in JavaScript. This format is easy for humans to read and machines to understand.
Collapse
var oBike = 
{
"color" : "Green",
"Speed": 200,
};
alert(oBike.color); //outputs "Green"
alert(oBike.Speed); //outputs 200
The above code creates an javascript object bike with two properties Color and Speed.
 
Q. Explain in brief about XMLHttpRequest object.
A. XMLHttpRequest object is used to transfer data between a client and a server. Here the client can be a web browser. Here, the client can send and receive data without reloading the page. It can be created as follow
Var request = new XMLHttpRequest ()
 
Q. What are the security issues with AJAX?
A. AJAX function calls are sent in plain text to server. These calls may easily reveal database details, variable names etc
User's browsing session can be monitored my maliciously inserting scripts
Ajax may encourage developers to use multiple server side pages thereby introducing multiple entry points for attackers
 
Q. Describe how to handle concurrent AJAX requests.
A. JavaScipt closures can be used for handling concurrent requests. A function can be written to handle such requests. Once processing of code is over, URL and the call back function to call can be passed as parameters. These parameters are passed to the AJAXInteraction(url, callback) object. Closures insure that the proper callback function associated with a specific AJAX interaction is called.
 
Q. Can Ajax be implemented in browsers that do not support the XmlHttpRequest object?
A. Yes. This is possible using remote scripts.
Q. When should AJAX NOT be used?
A. If the page is expected to be shown in a search engine like Google. Since Web crawlers don't execute javascript code.
If the browser does not support JavaScript. 
If security is a big concern in the application; Since Ajax allows end user to see half of what's being sent to the server.
Q.How do you know that an AJAX request has completed?
A.By determining the readyState property value of XMLHttpReqyest, One can know if the request is completed. If the readyState value = 4, the request has been completed and the data is available.
Q. How do I handle the back and forward buttons?
A. In order to store changes in the browsers web history (enabling back and forward buttons) Iframes can be used. Iframes allow am HTML document to be embedded in another HTML document. RSH (Really Simple History) framework can also be used. RSH framework explains the management of bookmarks and history for Ajax applications
Q. Can Ajax be implemented in browsers that do not support the XmlHttpRequest object?
A. In order to store changes in the browsers web history (enabling back and forward buttons) Iframes can be used. Iframes allow am HTML document to be embedded in another HTML document. RSH (Really Simple History) framework can also be used. RSH framework explains the management of bookmarks and history for Ajax applications
Q. How do I handle the back and forward buttons in AJAX?
A. While you could go out and create a custom solution that tracks the current state on your application I recommend you leave this to the experts. Dojo addresses the navigation in a browser neutral way as can be seen in the JavaScript example below.
function updateOnServer(oldId, oldValue,itemId, itemValue) {
var bindArgs = {
url: "faces/ajax-dlabel-update",method: "post",
content: {"component-id": itemId, "component-value":itemValue},
mimetype: "text/xml",
load: function(type, data) {
processUpdateResponse(data);
},
backButton: function() {
alert("old itemid was " + oldId);
},
forwardButton: function(){
alert("forward we must go!");
}
};
dojo.io.bind(bindArgs);
}
The example above will update a value on the server using dojo.io.bind() with a function as a property that is responsible for dealing with the browser back button event. As a developer you are capable of restoring the value to the oldValue or taking any other action that you see fit.
Q. How to we create an XmlHttpRequest object for Internet Explorer? How is this different for other browsers?
A. For Internet Explorer, an ActiveXObject is used for declaring an XmlHttpRequest object in Javascript.
//Code as below for IE: 
xmlHttpObject = new ActiveXObject("Msxml2.XMLHTTP"); 
//For Other browsers, code as below: 
xmlHttpObject = new XMLHttpRequest(); 
Note that XmlHttpObject used above is simply a variable for the respective browsers.
Q. What are the properties of the XmlHttpRequest object? What are the different types of readyStates in Ajax?
A. onreadyStateChange - This function is used to process the reply from the web server. readyState - This property holds the response status of the web server. There are 5 states:
  1. request not yet initialized
  2. request now set
  3. request sent
  4. request processing
  5. request completes
Site Navigation >