Ejemplo n.º 1
0
Sajax\Sajax::export(['testGet' => ['method' => 'GET'], 'testPost' => ['method' => 'POST'], 'getTheTime' => ['method' => 'GET'], 'test' => ['method' => 'GET'], 'sleep' => ['asynchronous' => false], 'otherFucntion' => ['uri' => 'example_otheruri.php']]);
// Handel the ajax request, script will exit here on ajax calls
Sajax\Sajax::handleClientRequest();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Example of Sajax Options</title>
<script type="text/javascript" src="json2.stringify.js"></script>
<script type="text/javascript" src="json_stringify.js"></script>
<script type="text/javascript" src="json_parse_state.js"></script>
<script type="text/javascript" src="sajax.js"></script>
<script type="text/javascript"><!--
<?php 
Sajax\Sajax::showJavascript();
?>
/**
 * Handel the return form the PHP function on return
 */
function print_result(v) {
    alert(v);
}
//-->
</script>
</head>
<body>
<!-- Testing if the browser supports GET -->
<button onclick="x_testGet(1, 2, 3, print_result);">Test GET</button>

<!-- Testing if the browser supports POST -->
Ejemplo n.º 2
0
<?php

/**
 * Dummy function
 *
 * @return string
 */
function otherFucntion() : string
{
    return 'URI: ' . $_SERVER['PHP_SELF'];
}
// Include the libery
require_once 'Sajax.php';
// Export the multiply with default options (empty array as value)
Sajax\Sajax::export(['otherefucntion' => []]);
// Handel the ajax request, script will exit here on ajax calls
Sajax\Sajax::handleClientRequest();