logo

What is this Ajax?

There are three days left this week, which gives me one a piece to cover the what, why and how of Ajax. Starting with what:

Well, it's not a Dutch football team or a kind of bleach! Ajax is a new name given to something which has been around for a while now, but without it's own catchy moniker.

Imagine using JavaScript to fetch XML from the server and include this data on the current page dynamically. This can all be done in the background, leaving the user unaware of the round-trip to the server. This is Ajax.

It's not a new idea and has been possible for a long time. Only now is it becoming more and more feasible to use this approach in anything other than the latest release of IE. Mozilla and Safari now support on-the-fly requests for XML.

Once upon a time you could get away with developing applications solely for use with IE. Not so any more. An increasing number of clients (mine at least) are requesting their applications feature dual support for IE and Mozilla (i.e. Firebird). In the past this would of ruled out the fancy stuff like on-the-fly lookups. With Ajax we can do some truly amazing stuff and rest assured it's going to work in all the latest browser releases. Cool.

Remember last year I talked about ways of preventing conflict documents on the web? The solution I came up with used an XML Island and was very IE-only (download). The same thing can be done with Ajax and work in other browsers too.

Tomorrow: why.

Comments

  1. May be i missed something but concretely there is nothing new in AJAX. there is no javascript api or framework... Nothing ! As Jesse James Garrett says :

    "Ajax isn’t something you can download. It’s an approach — a way of thinking about the architecture of web applications using certain technologies."

    So how could you say :

    "With Ajax we can do some truly amazing stuff and rest assured it's going to work in all the latest browser releases"

    For exemple, in your conflict stuff, what will you use that you didn't have last year to make it work in all the latest browser ?!?

    • avatar
    • Jake Howlett
    • Wed 27 Apr 2005 07:59

    Julien. This is just my interpretation of the "facts". I could well be wrong.

    Although my original code for the conflict thing could well be called an Ajax solution it's not what Jess thinks of as Ajax. From his article:

    Ajax incorporates:

    * standards-based presentation using XHTML and CSS;

    * dynamic display and interaction using the Document Object Model;

    * data interchange and manipulation using XML and XSLT;

    * asynchronous data retrieval using XMLHttpRequest;

    * and JavaScript binding everything together.

    It's the fourth point that brings it closer to cross-browser support. My conflict code used XML Islands, which have less support outside of IE than the XMLHttpReqeust object does. By using HTMLHttpRequests we can do it the same thing in most modern browser.

    Make sense?

    • avatar
    • Nick
    • Wed 27 Apr 2005 08:57

    Jake,

    Do you have any problems with caching of the XML document returned by the XMLHTTPRequest object? Firefox does not seem to cache the XML document but IE does, thus if you have updated a document and then try and reload the XML document into the current page by reloading the XMLHTTPRequest object, the changes are not reflected. The only way I have managed to get round this is to tag a random number onto the end of the url that I load eg ../people.xml?OpenView&53623.

    Any ideas?

    • avatar
    • Jake Howlett
    • Wed 27 Apr 2005 09:07

    Not seen that (yet) Nick. Doesn't surprise me though. What is your IE setting for caching? Try setting it to check for new versions every visit. Although you can't rely on this for all users, obviously, so the random string trick is probably a good idea.

  2. Nick,

    I had the same issue and came up with the same solution a while back myself. So far, I havn't found a way to fool proof the users individual settings, leaving us to assume we have to work around things like caching with a little slight of hand. As long as it's the XML document (e.g., one not bookmarkable) this is perfectly legit.

    One way to make it seem less kludgy is to use something meaningful for the random string, like the server time (URL encoded of course, in seconds, ala NotesDateTime object) then at least there is some potentially useful value, giving it an air of legitimacy, in your appended value and it's still relatively unique.

  3. Thanks Jake,

    HTMLHttpRequests work in all the latest browser releases... That's what i missed.

    • avatar
    • Jake Howlett
    • Wed 27 Apr 2005 09:48

    No worries Julien.

    Note: I just had a shock and worked out why it wasn't working in Safari for me. I have Safari 1.0.3. They didn't include XMLHttpRequest until 1.2. Doh. Not even sure I can upgrade with buying Tiger. Good excuse to swap my iBook for a Mac Mini though. If I wait two days I get Tiger with it (?)

    • avatar
    • Nick
    • Wed 27 Apr 2005 10:26

    Thanks Jake & Jerry,

    At least I'm not alone in using this method to work around IE's caching problem.

    I run Safari 1.3 on Panther (10.3.9) so you shouldn't need to upgrade, but the mac mini is very cool!

    • avatar
    • Jake Howlett
    • Wed 27 Apr 2005 10:35

    Agreed Nick. I just rang Apple and asked if ordering a Mac Mini today would mean it comes with Tiger. Since it takes two days to dispatch them and Tiger is released on Friday. She would only go as far as saying it would "probably" come with Tiger. If it didn't I would be eligible to upgrade for £11.99 though. Think I'll wait till Friday to order it.

    • avatar
    • Nick
    • Wed 27 Apr 2005 10:58

    I'd wait until friday to order. I'll be going to the Regent Street store on friday for my copy!

    • avatar
    • Jorge
    • Wed 27 Apr 2005 11:38

    In regards to the caching on IE would a meta tag on the url being access solved the problem. For example, a $ViewTemplate for the People view in the example above with the META taf would force the browser to grab the latest content.

    [META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE ]

    • avatar
    • Nick
    • Wed 27 Apr 2005 11:47

    Jorge,

    I think Meta tags aren't valid in XML documents.

  4. I'm not sure why everybody is jumping on the bandwagon with this.

    The standard 6.0 iNotes mail interface is a perfect example of an "Ajax" interface... and has been around for at least a couple of years.

    I use it all the time for when I'm on client sites and cannot connect directly using the client. It has all the drag-and-drop to folders, multiple selections, and rich-text editing that you'd expect. Take a good look at it, there is a huge amount of functionality in there. (Most of which I've lifted to use in my client apps. (^_^;)

    • avatar
    • Jake Howlett
    • Thu 28 Apr 2005 03:25

    Dragon. I'm "jumping on the band wagon" because an extremely useful technique has finally come of age and I want to make sure all my fellow Domino developers know about it.

    Good for you if you managed to rip apart iNotes. We're not all that intuitive though and many still rely on blogs like this to feed their imagination.

  5. Might be interested in reading this:

    {Link}

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:


About This Page

Written by Jake Howlett on Wed 27 Apr 2005

Share This Page

# ( ) '

Comments

The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »

Elsewhere

Here are the external links posted on the same day.

More links are available in the archive »

More Content