github.png
Drupal 7
I found this solid example for Drupal 7.
http://www.computerminds.co.uk/drupal-code/make-link-use-ajax-drupal-7-its-easy
The code for D7 is much more elegant, there are some great new features in D7 to make this stuff easier.
Drupal 6
Put this PHP code inside your module, e.g. sites/all/modules/my_module/my_module.module