xajax: Function returns value

This code has been tested with xajax V0.6 beta 1.

Before sending header:

require_once('xajax_core/xajax.inc.php');
$xajax = new xajax();
$xajax->configure('defaultMode', 'synchronous');
$xajax->register(XAJAX_FUNCTION, 'return_something');
$xajax->processRequest();

note:

  • line 3 – this must be added to make it work.
  • line 4 – define the name of function, see next section.

xajax function:

function return_something() {
    $r = new xajaxResponse()
    $r->setReturnValue('the value');
    return $r;
}

Calling the function to display the return value:

<a href="#" onclick="alert(xajax_return_something());>click me</a>

Leave a Reply

Your email address will not be published. Required fields are marked *