Top Ajax Interview Questions and Answers
Ajax isn’t a technology. It’s really several technologies, each flourishing in its own right, coming together in powerful new ways. Ajax incorporates:
- Standards-based presentation using XHTML and CSS;
- Dynamic display and interaction using the Document Object Model;
- Data interchange and manipulation using XML and XSLT;
- Asynchronous data retrieval using XMLHttpRequest;
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.
No. Or not yet. It is part of the DOM Level 3 Load and Save Specification proposal.
- Request not initialized
- Request set
- Request sent
- Request processing
- Request completed
The dynamically created page does not register itself with the browser history engine, so triggering the “Back” function of the users’ browser might not bring the desired result.
Network latency – or the interval between user request and server response – needs to be considered carefully during Ajax development.
3)Search Engine Optimization (SEO)
Comet – applications where the server keeps pushing – or streaming – data to the client rather than the browser polling the server for fresh content.
The Process of retrieving data from a server to obtain near-live data regularly is called AJAX polling.
The disadvantages of AJAX are:
- Search engines would not be able to index an AJAX application.
- The server information can not be accessed within AJAX.
- AJAX is not well integrated with any browser.
- ActiveX requests are enabled only in IE 5 or above
- Data of all requests is URL-encoded, which increases the size of the request.
Synchronous AJAX is a process that makes a java script to halt or stop the processing an application until a result is sent by a server. The browser is frozen, while the request is processed. The response time is 99.99% quick and fast enough. In case of intrusion for a request or transfer of the file, the browser freezes may be for two minutes until the time is out for the request. The advantages of using synchronous AJAX are, simple to code and can be used in the events ‘onunload’ and ‘onbeforeunload’.
An AJAX application introduces a layer between the user and the server which comprises of the AJAX engine. This eliminates the adhoc interaction between the client and the server and makes the application more responsive.
A browser loads an AJAX engine instead of the web page and then communicates with the server on users behalf as well as provides the user with an interface.
As the communication with the server in AJAX is asynchronous, the user doesn’t have to wait for a server response.
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.
- An AJAX interaction can only be made with the servers-side component from which the page was loaded.
- A proxy pattern could be used for AJAX interactions with external services.
- The application model should not be exposed as some user might be able to reverse engineer the application.
- HTTPS can be used to secure the connection when confidential information is being exchanged.