Tuesday, September 21, 2004

Look Ma, No Refresh

One of the biggest challenges of web application design is that any communication with the web server involves a round trip to the server, and a page refresh. A round-trip to the server cannot be avoided in most cases. After all, most of the application logic will rest of the server. However, page refreshes can be avoided completely by using some nifty JavaScript.

I wonder why I didn’t see this before. I think this has been DHTML’s best kept secret (as Simon Willison says in his Sitepoint article), and it took a post at the JavaScript Blog for me to start digging into it. The XMLHTTPRequest Object is probably one of the coolest things about JavaScript. With it, you can stream data over the HTTP stream back and forth between the server and the client without having to do a page refresh. The data is not necessarily formatted as XML (though in most cases it makes best sense to use XML, despite the slightly heavier code weight).

Now when I think about it, XMLHTTPRequest is used in practically every modern web application. Google’s GMail uses it to retrieve your mails without doing a page refresh, making the service lightning fast. Google’s Local uses an even more advanced script allowing you to zoom into and out of and re-center around a point in a map, to locate stuff of your interest in your locality. Amazon’s recently launched A9 uses it for creating and populating the various panes in their interface, making their interface highly interactive, responsive and fast.

I am definitely going to explore this in more detail as soon as possible. It is easy to see why this will be the single most important scripting trick to get comfortable with to make next generation applications for the web.

1 comment:

Sachin Nayak said...

Hi Rakesh,
First of all. Yes it is me. Anyway about this concept, did you know that this has been implemented in Whidbey, or VS 2005. They say that the method is simple. But I have given up believing until i see for myself (what i saw does not please the eyes).
Anyway, in Whidbey the concept can be achieved by doing something similar to the one u mentioned, except that they make the xml look like a string.