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.

About these ads

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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s





Follow

Get every new post delivered to your Inbox.

%d bloggers like this: