Topic: Cannot get ajax to work at all...javascript not defined error

I tried the example on the front page as well as the multiply example on the tutorials page. Every time I try to run it I get "Uncaught ReferenceError: xajax_doAdd is not defined" where doAdd is whatever the js function is. What am I missing? Heres the code:

<?php
require_once($_SERVER["DOCUMENT_ROOT"].'/lib/common/xajax/xajax_core/xajax.inc.php');

$xajax = new xajax();

$rqstAdd =& $xajax->register(XAJAX_FUNCTION, 'doAdd');
$rqstReset =& $xajax->register(XAJAX_FUNCTION, 'doReset');

// set the parameters
$rqstAdd->setParameter(0, XAJAX_JS_VALUE, 39);
$rqstAdd->setParameter(1, XAJAX_JS_VALUE, 571);

$xajax->processRequest();

function doAdd($a, $b)
{
    $response = new xajaxResponse();
    $response->assign('answer', 'innerHTML', $a + $b);
    $response->assign('reset', 'style.display', 'block');
    return $response;
}

function doReset()
{
    $response = new xajaxResponse();
    $response->clear('answer', 'innerHTML');
    $response->assign('reset', 'style.display', 'none');
    return $response;
}
?>
<html><head></head><body>
<form action="#" method="post">
<input type="button" onclick="<?php $rqstAdd->printScript(); ?>" id="btnAdd" value="Click Me" />
<input type="button" onclick="<?php $rqstReset->printScript(); ?>" id="btnReset" value="Reset" />
<p id="answer"></p>
</form>
</body></html>

Re: Cannot get ajax to work at all...javascript not defined error

That tutorial code is missing some important parts. For instance :

//This can go in your head or in the body, and will include xajax javascript and your defined functions in javascript.
<?php $xajax->printJavascript();?>