Been feeling kinda Anti-AJAX

Lately I’ve been trying to curb the overuse of AJAX. Basically it’s great that we can make all these calls to the server, but why make things so complicated. Why not just send all the data to the page and then handle it on the client side.

Thinking back to those kool Hello World Hello Ajax demo’s we all did back in 05 I wanted to revisit the classic cascading drop down scenario.

Let’s make it even easier and leave out JSON, JavaScript arrays and large methods (and by large I mean more than 5 lines) of JavaScript. Let’s let the DOM store the data and a couple lines of JQuery to do the rest.

I won’t bore you with the server side (use what every you want I)but here is the client side HTML.

image

The child dropdown contains all of the possible values and all options should initially be hidden. We are going to use the class of the option to store it’s parent ID. That is the key.

 

Then all we have to do is write a few lines of JQuery like this…

image

 

And that’s it.

1 Response to “Been feeling kinda Anti-AJAX”



  1. 1 Been feeling kinda Anti-AJAX Trackback on January 6, 2011 at 12:06 pm

Leave a comment