Whoops, just deleted my post.
Just as a point of discussion (and because I'm working on the WordPress vs. MODX book), it's interesting to look at how WordPress handles this -- it's similar ... check out
http://www.garyc40.com/2010/03/5-tips-for-using-ajax-in-wordpress/
Basically, the trick is passing PHP variables to Javascript. WordPress does this via the wp_localize_script() script, which ends up printing out a Javascript block in your HTML head.
<?php
$data = array();
$data['stuff']
$data['ajax_url'] = admin_url( 'admin-ajax.php' );
wp_localize_script( 'id_of_script', 'my_var', $data );
?>
Creates this:
<script type='text/javascript'>
/* <![CDATA[ */
var my_var = {"stuff":"value", "ajax_url":http:\/\/yoursite.com\/wp-admin\/admin-ajax.php"};
/* ]]> */
</script>
So I'm interested in how MODX passes PHP variables to Javascript.