Archive for January, 2011

Programming Poetry = FAIL

programming and poetry should never ever ever be combined. this does, however, explain jsonp in 26 words.

i have a new friend named jason p.
he likes to consume with me
we call cross-domain
but have to refrain
from POSTing requests
that’s insane

Advertisements

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.