Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When NOT to use AJAX in web application development? [closed]

Tags:

I'm building a web application with the Zend Framework. I have wanted to include some AJAX type forms and modal boxes, but I also want my application to be as accessible as possible. I want my application to be enhanced by AJAX, but also fully functional without AJAX.

So as a general guideline...when should I not use AJAX? I mean, should I bother making my application usable without AJAX? Or does everyone have AJAX enabled browsers these days?

like image 457
Andrew Avatar asked Nov 25 '09 21:11

Andrew


1 Answers

If you mean "accessible" in the ADA sense, AJAX is usually a no-no - your site should provide all its content and core functionality using only standard (X)HTML and CSS. Any javascript used should merely extend the core functionality, and your site should be coded to work elegantly in the absence of a javascript-enabled browser.

Examples: if you want a user to click on a thumbnail and get a full-size version of the image as a result, you can make the thumbnail a link. Then, the onclick event will fire a JQuery method that cancels the navigation behavior of the link and pops up a JQuery floating div to show the image on the current page. If the user's browser doesn't support JavaScript, the onclick event will never fire, and the user will be presented the image in a new page. The core functionality is the same with or without scripting.

EDIT: Skeleton example, sans JQuery-specific code.

<html> <body> <a href="some.url" onclick="JQueryToOpenPopupImage(); return false;">Some URL</a> </body> </html> 

To cancel the navigation operation, simply make sure that the method invoked by the onclick event returns false at the end.

A neat example of the JQuery image popup I described can be found here.

like image 85
Dathan Avatar answered Sep 22 '22 01:09

Dathan