Topic: xajax function in other function

How to realize xajax function in other function

<?php
require_once( "../xajax_core/xajax.inc.php" );

function ajax_func($InputData)
{
    global $xajax;

    $objResponse=new xajaxResponse();
    $objResponse->setCharacterEncoding("utf-8");
    $InputData = '';

    ajax_func2('15'); //What here code?

    return $objResponse;
}

function ajax_func2($InputData)
{
    global $xajax;

    $objResponse=new xajaxResponse();
    $objResponse->setCharacterEncoding("utf-8");

    $objResponse->alert('<pre>'. print_r ($InputData, true).'</pre>');
    $sum = $InputData + 25;
    
    $objResponse->Assign("msg", "innerHTML", $sum);

    return $objResponse;
}

$xajax=new xajax();
$xajax->configure("debug", true);
$xajax->register(XAJAX_FUNCTION, "ajax_func");
$xajax->register(XAJAX_FUNCTION, "ajax_func2");
$xajax->processRequest();
$xajax->configure('javascript URI','../');

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
    <head>
        <title>Redirect Test | xajax Tests</title>
        <?php $xajax->printJavascript( "../" ) ?>
    </head>
    <body>
        
    
    <div id="msg"></div>

    <form id="regForm" name="" onsubmit="return false;">
    <input type="text" name="name" value="name" size='27'>
    <input type="submit" name="submit" value="send" onclick="xajax_ajax_func(xajax.getFormValues('regForm')); return false;">
    </form> 

    </body>
</html>

Re: xajax function in other function

The answer came to me to mind later minutes 5 after the previous message.
Whether correct it?

function ajax_func($InputData)
{
    global $xajax;

    $objResponse=new xajaxResponse();
    $objResponse->setCharacterEncoding("utf-8");
    $InputData = '';

    //ajax_func2('15'); //What here code?

    return ajax_func2('15');
}

Re: xajax function in other function

Use $response->appendResponse(your_other_function([params])); in 0.6

Use $response->loadCommands(yur_other_function([params])); in 0.5

The other function must return a response object.

This allows both functions to participate with a single trip to the server.

Ed

If you ever stop learning you may as well dig a hole, crawl in and pull the top over yourself.