Sunday, January 11, 2009

Ajax Interview Questions

1) What is AJAX?

AJAX stands for Asynchronous JavaScript And XML.

With AJAX you can create better, faster, and more user-friendly web applications.

AJAX is based on JavaScript and HTTP requests.


2)What is XMLHttpRequest Object ?

Your JavaScript communicates directly with the server, through the JavaScript XMLHttpRequest object

By using the XMLHttpRequest object, a web developer can update a page with data from the server after the page has loaded!



3)Can Ajax be implemented in browsers that do not support the XmlHttpRequest object?

Yes. This is possible using remote scripts.

4)How to we create an XmlHttpRequest object for Internet Explorer? How is this different for other browsers?

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.

5)What are the properties of the XmlHttpRequest object? What are the different types of readyStates in Ajax?

i) onreadyStateChange - This function is used to process the reply from the web server.
ii) 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

Q)Which request is better with AJAX, Get or Post?

AJAX requests should use an HTTP GET request while retrieving data where the data does not change for a given URL requested. An HTTP POST should be used when state is updated on the server. This is in line with HTTP idempotency recommendations and is highly recommended for a consistent web application architecture.

Q)When do I use a synchronous versus a asynchronous request?

They don't call it AJAX for nothing! A synchronous request would block in page event processing and I don't see many use cases where a synchronous request is preferable

Q)Explain limitations of Ajax.

Back functionality cannot work because the dynamic pages don’t register themselves to the browsers history engine..........

Q)List out differences between AJAX and JavaScript.

Ajax is Asynchronous Java Script and XML. Here on Ajax sending request to the server, one needn’t wait for the.......

Q)When should AJAX NOT be used?

If the page is expected to be shown in a search engine like Google. Since Web crawlers don’t execute...............

Q)Are there any security issues with AJAX?

JavaScript is in plain view to the user with by selecting view source of the page. JavaScript can not access the local filesystem 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. You need to be careful not to expose your application model in such as way that your server-side components are at risk if a nefarious user to reverse engineer your application. As with any other web application, consider using HTTPS to secure the connection when confidential information is being exchanged.

No comments:

Post a Comment

 
Your Ad Here ]]>