sprnova
asked on
Xajax function not triggering event
I am using the following code found in an online tutorial to learn xajax but nothing comes up in the onclick event. Can anyone tell me what I am doing wrong?
<?php
require_once ("xajax/xajax_core/xajax.inc.php");
function slow_function()
{
$objResponse = new xajaxResponse();
sleep(2); //we'll do nothing for two seconds
$objResponse->addAlert("All done");
return $objResponse;
}
$xajax = new xajax();
$xajax->registerFunction('slow_function');
$xajax->processRequest();
?><html>
<head>
<title>Loading Bar Demo</title>
<? $xajax->printJavascript('xajax/'); ?>
</head>
<body>
<script type="text/javascript">
<!--
xajax.loadingFunction =
function(){xajax.$('loadingMessage').style.display='block';};
function hideLoadingMessage()
{
xajax.$('loadingMessage').style.display = 'none';
}
xajax.doneLoadingFunction = hideLoadingMessage;
// --></script>
<input type="button" onclick="xajax_slow_function();" value="Slow Function" />
<div id="loadingMessage" style="font-size: 22px; display: none;">
Loading...
</div>
</body>
</html>
ASKER
This displays the loading message but still no alert box.
<?php
require_once ("xajax/xajax_core/xajax.inc.php");
function slow_function()
{
$objResponse = new xajaxResponse();
sleep(2); //we'll do nothing for two seconds
$objResponse->addAlert("All done");
return $objResponse;
}
$xajax = new xajax();
$xajax->registerFunction('slow_function');
$xajax->processRequest();
?><html>
<head>
<title>Loading Bar Demo</title>
<? $xajax->printJavascript('xajax/'); ?>
</head>
<body>
<script type="text/javascript">
<!--
xajax.callback.global.onRequest=
function(){xajax.$('loadingMessage').style.display='block';};
function hideLoadingMessage()
{
xajax.$('loadingMessage').style.display = 'none';
}
xajax.callback.global.beforeResponseProcessing=hideLoadingMessage;
// --></script>
<input type="button" onclick="xajax_slow_function();" value="Slow Function" />
<div id="loadingMessage" style="font-size: 22px; display: none;">
Loading...
</div>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks that works!
xajax.loadingFunction =
function(){xajax.$('loadin
function hideLoadingMessage()
{
xajax.$('loadingMessage').
}
xajax.doneLoadingFunction = hideLoadingMessage;
...into this:
xajax.callback.global.onRe
function(){xajax.$('loadin
function hideLoadingMessage()
{
xajax.$('loadingMessage').
}
xajax.callback.global.befo