<?php
 
 
require_once "../class.pAjax.php";
 
 
 
function sameStructure() {
 
    // Recieved one argument with the following structure:
 
    //
 
    // + result (array)
 
    // |-+ [0] (struct)
 
    // | |-- teste (string) : "valüe"
 
    // | |-- a (number) : 0
 
    // |-+ [1] (array)
 
    // | |-- [0] (string) : "teste"
 
    // | |-- [1] (string) : "teste2"
 
    //
 
    // If I return the first argument recieved, I'll return the same structure to JS
 
    return func_get_args();
 
}
 
 
 
function firstArgument() {
 
    return func_get_arg(0);
 
}
 
 
 
$AJAX = new pAjax;
 
$AJAX->disableDomainProtection();
 
$AJAX->enableExportProtection();
 
$AJAX->export("sameStructure", "firstArgument");
 
$AJAX->handleRequest();
 
 
?>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
 
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
 
  <head>
 
    <title>Inline Ajax Call Test 2</title>
 
    <?php pAjax::showJavaScript(".."); ?>
 
    <script type="text/javascript">pAjax.setDebugMode(true);</script>
 
  </head>
 
 
  <body>
 
    <h1>Inline call test with 2 arguments</h1>
 
    <p>Struct sent to server:</p>
 
    <pre>
 
+ result (array)
 
|-+ [0] (struct)
 
| |-- teste (string) : "valüe"
 
| |-- a (number) : 0
 
|-+ [1] (array)
 
| |-- [0] (string) : "teste"
 
| |-- [1] (string) : "teste2"
 
    </pre>
 
    <script type="text/javascript">
 
        var func = function (e) {
 
            // "e" is the content of pAjax.getResponse()
 
            alert("e[0].teste = " + e[0].teste + "\ne[1][1] = " + e[1][1]);
 
        }
 
 
        var func2 = function (e) {
 
            alert("e.teste = " + e.teste + "\ne.a = " + e.a);
 
        }
 
 
        var o = {teste: 'valüe', 'a': 0};
 
        var a = ['teste', 'teste2'];
 
    </script>
 
    <input type="button" onclick="pAjaxCall(null, 'sameStructure', func, o, a)" value="Return the same structure!" />
 
    <input type="button" onclick="pAjaxCall(null, 'firstArgument', func2, o, a)" value="Return first argument: result[0]!" />
 
  </body>
 
</html>
 
 
 |