AHAH! It’s jQuery!

This was going to be a post about my first stab at AJAX. But, as technically it’s AHAH, I thought I’d use the lame title above…

This snippet uses jQuery – an excellent little piece of Javascript that makes this sort of trickery relatively simple.

Firstly, have a look at the basic syntax here: jquery.com/docs/ajax

A couple of things that I stumbled on:

  1. Content loaded via the .load call doesn’t have any event handlers attached, so in the Callback function you need to use .find() to look for any elements you want to assign events to.
  2. Getting the ID of the element clicked ended up being pretty simple: this.id
  3. Getting the value of a form field involves a simple walk around the DOM – as the form isn’t actually “Submitted” – use document.GetElementById(“fieldID”).value

Then you should end up with something more-or-less like this:

[syntax,ahah-jquery.js,javascript]

See it in use here: glenfosslyn.com.au/pages/2006-sale (This is a work in progress – it may or may not be working at the time you visit!)

Advertisements

One thought on “AHAH! It’s jQuery!

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