Online interview questions

Prepare interviews on Anything, AnyWhere

PHPSCOTS
PHPSCOTS
Blogger, Developer Views: 1086

Ajax Interview Questions

Top Ajax Interview Questions and Answers

1. What’s AJAX?

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.

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;
  • And JavaScript binding everything together.

2. Does AJAX work with Java?

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.

3. Is the XMLHttpRequest object part of a W3C standard?

No. Or not yet. It is part of the DOM Level 3 Load and Save Specification proposal.

4. List the different types of readyStates in Ajax?

  • Request not initialized
  • Request set
  • Request sent
  • Request processing
  • Request completed

5. Explain limitations of Ajax.

1)Browser Integration

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.

2)Response-time Concerns

Network latency – or the interval between user request and server response – needs to be considered carefully during Ajax development.

3)Search Engine Optimization (SEO)

Websites that use Ajax to load data which should be indexed by search engines must be careful to provide equivalent Sitemaps data at a public, linked URL that the search engine can read, as search engines do not generally execute the JavaScript code required for Ajax functionality.

4)Reliance on JavaScript

Ajax relies on JavaScript, which is often implemented differently by different browsers or versions of a particular browser. Because of this, sites that use JavaScript may need to be tested in multiple browsers to check for compatibility issues.

6. 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.

7. Explain AJAX polling.

The Process of retrieving data from a server to obtain near-live data regularly is called AJAX polling.

8. What is the disadvantage of AJAX?

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.

9. What is synchronous request in AJAX?

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’.

10. How Ajax is different?

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.

11. Describe how to handle concurrent AJAX requests.

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.

12. Are there any security issues with AJAX?

  • A JavaScript can not access the local file system without the user’s permission.
  • 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.