views:

35

answers:

2

I'm about to build a web application(not web presentation) which will load its content through AJAX (jQuery) into a specific div. There will be a menu above the div and when a user clicks on an item from the menu, the appropriate page will be loaded into the main div.

I'd like to know if there are any cons and pros of choosing this pattern for a web application.

So far I'm avare that the browser back button and history/url will be gone.

+3  A: 

Two possible downsides are that it could make it difficult for users to bookmark content on your site and difficult for search engines to differentiate pages on your site.

You should probably provide more information on your reasons for taking this approach. You might have good reasons or it might be a case of using a technology (AJAX) because it is cool to use.

If you want to give the users the impression of fast responsiveness, then yes AJAX load your pages, but still have a different url for each page. This will take more code but it will solve both issues that I mentioned.

  http://yourdomain.com/home.aspx //loads its own content via AJAX

  http://yourdomain.com/contact.aspx //loads its own content via AJAX

  etc

This is really only appropriate if you have a lot of content, or where the content involves time-consuming calculations, such as on a financial site. In most cases, it would be less trouble to just load your pages normally or break you content into paged chunks.

Daniel Dyson
I'm using a javascript component library which builds a nice, deskop application looking layout. The problem is when I go to any other page I have to rebuild this layout for the current page. There for I thinking about loading the content through AJAX.
That's what I meant by more information. Sounds like a good reason to use AJAX then, and @lonesomeday's idea sounds worth looking into. Any particular reason not to implement RIA in Silverlight?
Daniel Dyson
Any particular reason not to implement RIA in HTML/ JS ? :-) The developers in our are more familiar with HTML/JS and I read this article http://codeclimber.net.nz/archive/2010/09/02/Is-Silverlight-becoming-a-niche-technology.aspx
Good point. I guess, from my perspective the widespread deployment of HTML5 browsers is a lot further off than Silverlight. I work in investment banking where the upgrade from IE6 is typically still a matter of 1 to 2 years off. Not kidding. Don't even mention Chrome. We can't get it installed widely. They have a very slow upgrade cycle, as do a lot of big corporates. So in my world, Silverlight, Flash and Java are the only options for RIAs. Although jQuery is changing that to some extent. Thanks JQuery. Make sure you let us know how you get on with the hashchange plugin. It looks interesting.
Daniel Dyson
+1  A: 

The main con of this approach this will make your site very difficult for search engines to crawl. They don't read Javascript, so your content won't get seen or indexed by them. Try to do progressive enhancement so that they (and any users who don't use Javascript, e.g. screen-readers) don't get left behind.

On the other hand, you can keep browser history functionality. This can be done using the URL hash, e.g. http://www.example.com/#home vs http://www.example.com/#about-us. The nicest way to do this is to get Ben Alman's hashchange plugin and then use the hashchange event:

$(window).hashchange(function(){
    var location = window.location.hash;

    //do your processing here based on the contents of location
});

This will allow your users to use the history function and the bookmarking function of their browsers. See the documentation on his site for more information.

lonesomeday
Thank you for your response. The app will be RIA application which uses a javascript component framework so there won't be users without JS :-) The hashchange plugin looks very interesting, I'll definitely have a look at it.
@user If you're building a RIA, you might be interested in the hashchange plugin's big brother, [BBQ](http://benalman.com/projects/jquery-bbq-plugin/), which allows you to store lots of information in `location.hash`.
lonesomeday