6 Places You Must Use Ajax

[ 2005-12-05 14:05:28 | Author: todd ]
Font Size: Large | Medium | Small
  随着所谓的“Web2.0”概念的广泛传播,人们也越来越重视用户体验(UE)这一个在软件工程中本来就很重要,但一直被人们所忽略的地概念。与此同时,Ajax的出现,确实吸引许多web技术人员,尤其是客户端脚本技术人员都疯狂的追求新技术带来的快感。Gmail、Google Maps、Flickr等一系列大碗对Ajax的应用,更是让人们看到了互联网新的春天。于是:“Ajax是优化用户体验的最好手段”。

  但实际上Ajax是否真的能够满足我们的那些功能需求么?Ajax是不是唯一的解决方案呢?有没有其他更合理的方式可以使用呢?很久以前的Ajax七宗罪已经把Ajax的弊端说得很全面了;同时网上也出现了许多反对七宗罪的文章,把七宗罪一一推翻。各种各样的评论,这里也就不一一列举了。

  但是最终大家能够得到的结论,恐怕最有价值的就是“我们应该合理的应用Ajax”(这少我认为这些宣扬多日的讨论只能总结出来这一点了)。

  如何合理的应用Ajax呢?这件事大家还都在探索,总结各自的经验。我也是在一些项目的实际应用中慢慢学习。

  不过今天看到一篇文章,对在哪些地方应该应用Ajax,哪些地方不应该应用总结的很不错。可以对我们今后的一些项目有所指导。放在这里大家分享一下:
Quote
It's been well over a year now since GMail changed the way everyone thought about web apps.

It's now officially annoying to use web apps that haven't replaced clunky html functionality with peppy Ajax goodness.

Here are places Ajax should now be required in a web application:
  • Form driven interaction.
  • Forms are slow. Very slow. Editing a tag on a del.icio.us bookmark? Click on the edit link to load the edit bookmark form page, then edit the field and hit submit to wait for the submission to go through, then return to the previous page and scroll down to find the bookmark to see if the tags look right. Ajax? Click on the edit link to instantly start changing tags, click on the submit button to asynchronously send off changes to the tags and quickly see in place what changed, no reloading the entire page.

  • Deep hierarchical tree navigation.
  • First of all, applications with deep hierarchical tree navigation are generally a nightmare. Simple flat topologies and search/tagging works very well in most circumstances. But if an application really calls for it, use Javascript to manage the topology ui, and Ajax to lessen the burden on the server by lazy loading deep hierarchy data. For example: it's way too time consuming to read discussion threads by clicking through and loading completely new pages to see a one line response.

  • Rapid user-to-user communication.
  • In a message posting application that creates immediate discussions between people, what really sucks is forcing the user to refresh the page over and over to see a reply. Replies should be instant, users shouldn't have to obsessively refresh. Even Gmail, which improves on the old hotmail/yahoo mail 'refresh inbox, refresh inbox' symptom, doesn't really push Ajax far enough yet in terms of notifying new mail instantly.

  • Voting, Yes/No boxes, Ratings submissions.
  • It's really too bad there are no consistent UI cues for Ajax submission, because submitting a vote or a yes/no response is so much less painful when the submission is handled through Ajax. By reducing the time and impact of clicking on things, Ajax applications become a lot more interactive - if it takes a 40 seconds to register a vote, most people would probably pass unless they really care. If it takes 1 second to vote, a much larger percentage of people are likely to vote. (I have 2008 movie ratings on Netflix versus 210 ratings on IMDb.com).

  • Filtering and involved data manipulation.
  • Applying a filter, sorting by date, sorting by date and name, toggling on and off filters, etc. Any highly interactive data manipulation should really be done in Javascript instead of through a series of server requests. Finding and manipulating a lot of data is hard enough without waiting 30 seconds between each change in views, Ajax can really speed this up.

  • Commonly entered text hints/autocompletion.
  • Entering the same text phrases or predictable text phrases is something software/javascript can be good at helping out with. It's very useful in del.icio.us and GMail, for quickly adding tags/email addresses.
For heavy use applications such as a webmail client or a blogreader, users have the luxury of time to learn new UI concepts, and the frustration of interacting with a slow interface. This kind of application is a perfect opportunity to leverage Ajax everywhere. The more frequently users use an application, the more Ajax should be powering that use.

However for most web applications, it doesn't make any sense to use Javascript for everything or even anything. Ajax only really clearly helps in a limited set of circumstances; the web already worked pretty well before Ajax and there are a lot of pitfalls and drawbacks to using Ajax in web development. A straight html weblog works just fine without being generated dynamically on the client with a stream of asynchronous messages from the server. Plain old HTML also works great for documents, or navigating between documents. Simple or rarely used applications can get along fine without putting in a bunch of Javascript.

Here are some places Ajax shouldn't be used:
  • Simple forms.
  • Even though forms are the single biggest beneficiary of Ajaxification, a simple comment form, or submit order form, or other one-off rarely used form does not benefit from Ajax driven submission. Generally, if a form is not used much, or it's critical to work properly, Ajax is not that helpful.

  • Search.
  • LiveSearch on blogs is more annoying than useful. There's a reason that Google Suggest is staying in beta and not going on the front page of Google. Searching on Start.com Live.com doesn't allow use of the back button to see a previous search, or previous pages. Maybe it's possible that no one has gotten this right yet, but getting this right is hard enough that it's generally not a good idea, or more trouble that it's worth.

  • Basic navigation.
  • In general, driving basic site/application navigation using Ajax is an awful idea. Why would anyone want to spend time writing code to emulate the browser behavior when they could spend time making their application better? For basic navigating between documents, Javascript doesn't help.

  • Replacing a large amount of text.
  • Ajax saves a complete refresh of the page, so small pieces of the page can be more dynamically updated. But if nearly everything on a page is changing, why not just request a new page from the server?

  • Display manipulation.
  • Even though it seems that Ajax is purely a UI technology, it's not. It's actually a data synchronization, manipulation and transfer technology. For maintainable and clean web applications, it's a good idea not to have Ajax/Javascript manipulate the interface directly at all. Javascript can stay separate and simply manipulate the XHTML/HTML DOM, with CSS rules dictating how the UI displays that data. See this post for a simple example of using CSS instead of Javascript to control display.

  • Useless widgets.
  • Sliders, drag and drops, bouncies, mouse gestures, whatever. Mostly these widgets can be replaced with more intuitive controls, or eliminated altogether in favor of simplicity. In picking colors, maybe a slider widget is useful to pick the exact shade. But in picking a price point in a store, a slider to pick the price to the cent is just overkill.
Many good points, not all agreeable
I am sure that we will all agree with some of the points, and disagree with others. You also can't paint a brush this thick. There are some live searches that are great. We have worked on a few domain specific live searches that really helped the users in usability testing.

Simple forms are also one of the places where Ajax should definitely be used! With Ajax you can have real time error checking (including domain specific validation, not just "is it a number"). It is also something that is easy to degrade.
原文来自 Alex Bosworth's Weblog
[Last Modified By todd, at 2005-12-05 14:46:07]
Comments Feed Comments Feed: http://www.todd-lee.com/blog/feed.asp?q=comment&id=130

There is no comment on this article.

Post Comment
Username:   Password:   Register Now?
Security Code * Please Enter the Security Code
Smilies
[smile][confused][cool][cry][angry][wink][sweat][lol][stun][razz][redface][rolleyes][sad][heart][star][idea][black][rage][weep][amaze][ruin][evil][imprintMale][imprintFemale][scare][smoke][letch][brick][retch][warm] [rabbit][cat][mummy][lovely][zizz][power]
Enable UBB Codes Auto Convert URL Show Smilies Hidden Comment