<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" 
      xmlns:thr="http://purl.org/syndication/thread/1.0">
  <link rel="alternate" type="text/html" href="http://www.insideria.com/2008/03/examples-of-ajax-usability-mod.html" />
  <link rel="self" type="application/atom+xml" href="http://www.insideria.com/atom.xml" />
  <id>tag:www.insideria.com,2009://34/tag:www.insideria.com,2008://34.23034-</id>
  <updated>2009-11-16T15:52:01Z</updated>
  <title>Comments for Examples of Ajax Usability Modifications (http://www.insideria.com/2008/03/examples-of-ajax-usability-mod.html)</title>
  <generator uri="http://www.sixapart.com/movabletype/">Movable Type 4.21-en</generator>
  <entry>
    <id>tag:www.insideria.com,2008://34.23034</id>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2008/03/examples-of-ajax-usability-mod.html" />
    <link rel="service.edit" type="application/atom+xml" href="http://blogs.oreilly.com/cgi-bin/mt/mt-atom.cgi/weblog/blog_id=34/entry_id=23034" title="Examples of Ajax Usability Modifications" />
    <published>2008-03-05T15:14:38Z</published>
    <updated>2008-03-05T15:38:48Z</updated>
    <title>Examples of Ajax Usability Modifications</title>
    <summary>
Let me start off by saying that I am - in no way - a usability expert. I hardly even consider myself an Ajax expert. But I&apos;ve built enough Ajax applications now where I&apos;m beginning to think more and more about the usability aspects of the site. I recently had an opportunity to make improvements to one of my sites based on user feedback, and I thought I&apos;d share what I did and get people&apos;s opinions about how I could have done it better.</summary>
    <author>
      <name>Raymond Camden</name>
      <uri>http://www.coldfusionjedi.com</uri>
    </author>
    
    <category term="Blogs" />
    
    <content type="html" xml:lang="en" xml:base="http://www.insideria.com/">
      <![CDATA[<p>Let me start off by saying that I am - in no way - a usability expert. I hardly even consider myself an Ajax expert. But I've built enough Ajax applications now where I'm beginning to think more and more about the usability aspects of the site. I recently had an opportunity to make improvements to one of my sites based on user feedback, and I thought I'd share what I did and get people's opinions about how I could have done it better.<br />
<span class="mt-enclosure mt-enclosure-image"><img alt="" src="http://www.insideria.com/upload/2008/03/examples_of_ajax_usability_mod/cfbloggers.png" width="201" height="300" class="mt-image-right" style="float: right; margin: 0 0 20px 20px;"/></span><br />
After ColdFusion 8 launched, I decided to build a showcase for the new Ajax functionality. I developed <a href="http://www.coldfusionbloggers.org">ColdFusionBloggers</a>, an aggregator of ColdFusion blogs, as a way to play with and show off what ColdFusion 8 could do in the Ajax arena. (As a side note, it also makes heavy use of other CF8 features like &lt;cfthread&gt; and &lt;cffeed&gt;.) In creating the site, I went all out. Every possibly place I could use Ajax - I did. I probably went a bit too far, but hey, it was fun.</p>

<p>A few days ago I got some good feedback about a few issues with the site. The first issue involved pagination. If you click the Next or Previous link on the site, you will notice that the content changes, but not the entire page. This was accomplished rather easily using the &lt;cfdiv&gt; tag. I didn't need JavaScript at all for the links, as ColdFusion handled all the Ajax HTTP requests for me behind the scenes. Incredibly easy - and incredibly helpful as the pagination now was much quicker than forcing a complete page reload. </p>

<p>One problem though involved users who came back to the site after visiting a link. If they were on page 2 for example, clicked to follow a link and then hit Back in the browser, they would end up back on page 1. So how could I solve it? </p>

<p>I've noticed on other Ajax-based sites that hash marks (foo.com/index.cfm#Something) were used to differentiate different 'states' or 'pages' within the application. I decided to use this for the site. Whenever you click Next or Previous, I'll update a page value in the URL. I switched to the following code:</p>

<p>next = function(u) {<br />
	document.location.href = '###np#';<br />
	ColdFusion.navigate(u,'content');<br />
	document.body.scrollTop=0;<br />
}</p>

<p>The #np# portion represents the next page. This involves some ColdFusion code I'm not pasting in, but basically, if we are on page 3, then np will equal 4. The ColdFusion.navigate function is a JavaScript function automatically included on pages using ColdFusion's Ajax features. As you can guess, it sends a particular content block (like a DIV) to a new URL. My next link passes in the next URL via the u arguments. So all in all, I first change the location of the browser to the next page, from #3 for example to #4, and I then push the DIV with the content to the new URL. (I'll explain the last line later.) The previous link code works pretty much the same.</p>

<p>Ok - so far so good. I noticed I could follow a link and hit back and if I had #N in the browser, it returns. The next issues was getting the server side code to actually recognize the #N. This turned out to be a bit more difficult then I imagined. I had assumed that everything about a URL would end up as a CGI variable. It seems the anchor values are not. I guess that makes sense in a way since an anchor link (ie, linking to another anchor in a page) doesn't create a new server request, but, I had assumed that if the anchor was there in the <em>initial</em> URL, it would be there in the CGI scope. No such luck.</p>

<p>I began to reconfigure index.cfm. This is the core file of the site. The first thing I did was add code to run a JavaScript function on page load. </p>

<p>&ltcfset ajaxOnLoad("loadContent")&gt;</p>

<p>This is a convenience function for ColdFusion applications that use Ajax. I then created the following JavaSciprt:</p>

<p>function loadContent() {<br />
	var baseurl = 'content.cfm?';<br />
	if(document.location.hash != '') baseurl+= 'page='+document.location.hash.substr(1,document.location.hash.length);<br />
	ColdFusion.navigate(baseurl,'content');<br />
}</p>

<p><br />
This code looks for #N in the URL. If it exists, it passes it as a normal query string variable to my content div. Hopefully this makes sense!</p>

<p>The last tip I was given involved scrolling. I include Previous and Next links both on top and at the bottom of my main content div. If a user was at the bottom of the page and hit the Next link, they would stick at the bottom when the content loaded the new page. Sticking in the document.body.scrollTop=0; corrected that issue. </p>

<p>So any comments on what I did? While it worked, I wonder if there is a better solution. How many other Ajax developers are now feeling comfortable enough to worry about issues like this?</p>]]>
      
    </content>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2008://34.23034-comment:2015664</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2008://34.23034" type="text/html" href="http://www.insideria.com/2008/03/examples-of-ajax-usability-mod.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2008/03/examples-of-ajax-usability-mod.html#comment-2015664" />
    <title>Comment from Jim Priest on 2008-03-05</title>
    <author>
        <name>Jim Priest</name>
        <uri>http://www.thecrumb.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://www.thecrumb.com">
        <![CDATA[<p>I think it works much better!  </p>

<p>I'm struggling with some of the same things.  Usability and lately trying to test my application using tools like Selenium which doesn't play nicely with some of the Ajax/jQuery things I've done.  </p>

<p>And since I work for the Government - 508 compliance is looming as well.  </p>]]>
    </content>
    <published>2008-03-05T17:15:07Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2008://34.23034-comment:2105916</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2008://34.23034" type="text/html" href="http://www.insideria.com/2008/03/examples-of-ajax-usability-mod.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2008/03/examples-of-ajax-usability-mod.html#comment-2105916" />
    <title>Comment from Steven on 2009-09-19</title>
    <author>
        <name>Steven</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>The biggest pain of using ajax is truthfully backward compatibility with browsers where javascript is disabled. I develop UI for <a href="http://hintcafe.com">web dating</a> site and use ajax for stuff like file uploading etc. The tricky part is giving a good and functional web UI for users who disable javascript in their browsers.</p>]]>
    </content>
    <published>2009-09-19T22:24:04Z</published>
  </entry>

</feed
