Should I use Ajax?

Question

Is it really necessary to use Ajax? Can not we just make use of simpler techniques like iframes? Or DHTML?

Short answer

Ajax becomes necessary when you want a dynamic site or pages, and that they be updated by loading data from the server, after the display, at the request of the user, or to renew the content.

Long answer

The asynchronous mode and XMLHttpRequest

Ajax, in addition to the components of Dynamic HTML, including JavaScript, CSS, DOM, has the asynchronous mode that is provided by the XMLHttpRequest object.

Ajax or iframes?

IFrame is another mean for changing a web page instantaneously without reloading it, with data taken from the server. IFrames help to integrate a content from other pages, but this content is not part of the current page, it can not directly be accessed from it and modified. Iframes are perfect to view additional content from the same site or another site.
An example of iframe is given by the CSS Tab Panel that allows to display pages or images selected by the user.
The contents are displayed in an bounded area while Ajax can change any element of the page itself.

XMLHttpRequest object has the following benefits over iframes: 
- It allows exchanging XML file with the server, that become accessible with the DOM interface, IFrame doesn't. 
- It is faster and easier then IFrame. 
- It has the abort() function. 
- Numerous frameworks are dedicated to Ajax. 
IFrame should be used only when XHR is not available, on older Web browsers for example.

More infos
© 2009-2012 Xul.fr