Thoughts On AJAX

Wednesday, August 10, 2005

Wally asks: “What is AJAX?”

I hope AJAX will be invisible. I hope developers don’t have to think about AJAX anymore than they think about the inner details of the HTTP protocol. I have no inside information on the ASP.NET team’s Atlas project yet, but I’m hoping to use it like so:

<asp:Image runat="server" ID="MagicImage"

           ImageUrl="32457.png"

           AsyncPostBack="true"

           OnDrag="MagicImage_OnDrag"

/>

The above snippet demonstrates two features:

1. High frequency events like ondrag, which we previously could only handle with client side script, will be available on the server.

2. The presence of an AsyncPostBack property indicating a control initiates a “lightweight” postback.

JavaScript would perform the lightweight postback asynchronously. The script should communicate back to the server with as little payload as possible, but with enough information (viewstate and other form values) to execute the typical page lifecycle.

On the server, life goes on as usual. We respond to events using .NET code, execute queries, data bind controls, set control properties - yadda, yadda. During the MagicImage_OnDrag event, we might set the control’s ImageUrl property to a new value. A new Page property, IsAsyncPostBack, will let us skip code that we know we don’t need to execute during a lightweight postback.

The server responds by grabbing rendered HTML for the controls marked with AsyncPostBack=”true” and piping bits back down the wire. Client side script parses instructions in the results and updates a subset of form fields and controls using the DOM.

All of the JavaScript I’m talking about is baked into the framework. All I need to do is set an AsyncPostBack property, wire up an event handler, and write C# code.

Too simplistic?


Comments
Aaron Wednesday, August 10, 2005
I'm wondering how the "high frequency" ondrag event could be handled on the server in any what of "lightweight" way. It seems to be high frequency by definition. The http calls being built up and torn down on both client and server would be some heavy overhead -- wouldn't it?

I like the idea of simplicity and I imagine much smarter people than I will be trying to solve this problem. Thanks for sharing your vision.
Hermann Klinke Wednesday, August 10, 2005
Yeah, that's also how I would like to use it. There is nothing too simplistic in the software world!
scott Wednesday, August 10, 2005
Aaron, good point.

The ondrag event might not be the best example - perhaps a bit too high frequency. I expect AJAX / Atlas to give me the ability to respond to image clicks and panel double clicks to make a page "highly interactive" like virtual earth / google maps.

It's going to cause nightmares in the load testing lab for many people I'm sure.
Milan Negovan Thursday, August 11, 2005
I think out-of-band calls should absolutely be a part of the server-side life cycle to be even remotely useful to ASP.NET devs. In my opinion, Atlas is the most formidable undertaking in this area, Michael Schwarz's library being a very close second.

As to "What is AJAX?", I've shared my thoughts at www.aspnetresources.com/... (if you don't mind my shameless plug :)
scott Thursday, August 11, 2005
I don't mind shameless plugs. I know I've done a few myself :)
Tobin Titus Saturday, August 13, 2005
If you don't mind shameless plugs, what about JAXASS (www.jaxass.org)? This technology promises to wrap up the cure for cancer, colonize Mars, and provide an extra inch to your member all with a JAXASS web tag! This works by simply implementing existing medical,rocket science, and urological studies under one monogram and crediting their creation to myself -- the all powerful Toby "McGuire" Titus
scott Saturday, August 13, 2005
Yes - I have seen the JAXASS movement on your sight, Tobin. I just want to know: what can JAXASS do about our reliance on fossil fuel? AJAX can't do squat.
Comments are now closed.
by K. Scott Allen K.Scott Allen
My Pluralsight Courses
The Podcast!