|
|
To AJax or not to Ajax, that is the question !
back
Love it or hate it, Ajax is here to stay. The momentum is taking off with the wave of Web 2.0 web applications being rolled out in recent months. For a web developer, Ajax requires a different way of thinking, as the traditional round trip communication between the web server and the browser is no longer necessary. The data returned to the browser no longer has to have a full xhtml compliant structure to be rendered. In fact, they can be injected into any existing html element on the page and be considered structurally part of that page (there must be some security implications here, surely ?!). Why is this a good thing ? Think interactivity ! You can allow visitors to vote, take surveys, chat etc. without ever leaving the page. Sure, all this used to be made possible using hidden frames and iframes, but the advantage is the new Ajax model ensures all the elements are still part of the same page and you do not have to traverse the DOM (Document Object Model) to get to the part of the page you want to update.
I like Ajax because :
Ajax calls are more bandwidth efficient. If you have a large page with mostly static text and only portions of it need to be changed per request, Ajax provides a better mechanism for doing this than standard form submit
The auto-complete feature (like in Google Suggest) is more user friendly than selecting from a dropdown or a page full of alphabet letters
A typical Ajax request can have individual hooks for the life of the request, giving you a much better way to inform the user of the progress as the call is being completed
You can put it on your CV/Resumé that you have done it
Ajax is great for hiding your HTML source. If you use Ajax to deliver the more sensitive contents, your competitors will have great diffculty trying to reverse engineer your code (although if he is really determined, he will find a way !).
I do not like Ajax because (well, to be more precise, these are the gotchas) :
Ajax can not be used for uploading binary data like images or PDF's
The auto-complete feature can generate massive number of round trip requests to the server, which could potentially skew the performance analytics on the site. Also, network latency can in a way spoil the user experience for this feature
You can not push Adsense ads into an Ajax response. Google Adsense is the way most webmasters generate income on the side, and it needs to be able to crawl your site for the page it was embedded in, in order to deliver the relevant ads. As Ajax calls are injected into the page, the contents are invisible to Google Adsense
An Ajax enabled page is stateful, meaning it preserves the context for the interactions you have made with the page. If you click on the Back button on your browser, this context is completely destroyed and you have to start from scratch again. You can implement Ajax patterns to support the Back button, but this will have to be designed into each page
Ajax is a nightmare to debug, specially because the Ajax contents can not be viewed using the conventional right click, View source ... trick
Ajax uses Javascript extensively, this means you have to reach a certain degree of competence with Javascript if you want to do anything more sophisticated than Hello World. Also the other two bad side effects with Javascript are:
- some search engines are blind to Javascript, or can not index it properly
- if you have a confirmer (e.g. Are you sure you want to delete this very important record ? (Y/N)) on a Javascript URL, it is completely ignored by the bots, so do not be surprised if all your subscribers get cleaned out the morning after the crawler visited your site
Can anything be done in Ajax that can not be achieved with tradditional web techniques ? I have not found any yet. Then why should developers adopt Ajax ? I think this is not a yes or no kind of answer. A mix of the two is probably the best way to achieve your goal. Ajax is not the best thing since Heinz Baked Beans, but it has its uses.
You can see from this site that evidence of Ajax is everywhere, so I use it very extensively. It means I do get the headache with the issues above, but in the end it can be worthwhile doing it, specially with the demanding web audience of today.
back
by by David at 06 Jul 2006 21:06:13
|
|