As an update...from http://codex.wordpress.org/AJAX_in_Plugins:
--------
First, add some javascript that will trigger the AJAX request:
<?php
add_action('admin_head', 'my_action_javascript');
function my_action_javascript() {
?>
<script type="text/javascript" >
jQuery(document).ready(function($) {
var data = {
action: 'my_special_action',
whatever: 1234
};
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
jQuery.post(ajaxurl, data, function(response) {
alert('Got this from the server: ' + response);
});
});
</script>
<?php
}
Then, set up a PHP function that will handle that request:
<?php
add_action('wp_ajax_my_special_action', 'my_action_callback');
function my_action_callback() {
global $wpdb; // this is how you get access to the database
$whatever = $_POST['whatever'];
$whatever += 10;
echo $whatever;
die();
}
-----
Is this how it should be done? I can see there are some differences in my implementation, mostly that it looks like this is triggered using some WP hook instead of how I did it with a user clicking. To me though, it looks like the example would fire everytime the page is loaded.
Once again any info would be greatly appreciated.