Esempio n. 1
0
 * Get the current date
 *
 * @return string
 */
function getTheTime() : string
{
    return date('Y-m-d h:i:s');
}
// Include the libery
require_once 'Sajax.php';
// Uncomment the following line to turn on debugging
//Sajax\Sajax::$debugMode = true;
// Set redirect page in case of error (only works when not debugging)
Sajax\Sajax::$failureRedirect = '/sajaxfail.html';
// Export methodes with options
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();
Esempio n. 2
0
function refresh(int $lastrefresh)
{
    global $filename;
    if (filemtime($filename) > $lastrefresh) {
        $lines = file($filename);
        // return the last 25 lines
        return ['wall' => join("\n", array_slice($lines, -25)), 'update' => filemtime($filename)];
    }
    return false;
}
// Include the libery
require_once 'Sajax.php';
// Set redirect page in case of error
Sajax\Sajax::$failureRedirect = '/sajaxfail.html';
// Export methodes
Sajax\Sajax::export(['addLine' => ['method' => 'POST'], 'refresh' => ['method' => 'GET']]);
// 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>Sajax graffiti wall example</title>
<style type="text/css">
.date {
    color: blue;
}
</style>
<script type="text/javascript" src="json_stringify.js"></script>
<script type="text/javascript" src="json_parse.js"></script>
Esempio n. 3
0
 */
function returnString() : string
{
    global $age;
    return "Anders is " . floor($age) . " years old.";
}
// Include the libery
require_once 'Sajax.php';
// Set default request methode to GET (only other option is POST)
Sajax\Sajax::$requestType = 'GET';
// Uncomment the following line to turn on debugging
//Sajax\Sajax::$debugMode = true;
// Set redirect page in case of error (only works when not debugging)
Sajax\Sajax::$failureRedirect = '/sajaxfail.html';
// Export methodes with default options (empty array as value)
Sajax\Sajax::export(['returnArray' => [], 'returnObject' => [], 'returnInt' => [], 'returnFloat' => [], 'returnString' => []]);
// 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>
<title>Sajax PHP return types example</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<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();
Esempio n. 4
0
 * @param float $secoundNumber Number to multiply with
 *
 * @return return float
 */
function multiply(float $firstNumber, float $secoundNumber) : float
{
    return $firstNumber * $secoundNumber;
}
// Include the libery
require_once 'Sajax.php';
// Uncomment the following line to turn on debugging
//Sajax\Sajax::$debugMode = true;
// Set redirect page in case of error (only works when not debugging)
Sajax\Sajax::$failureRedirect = '/sajaxfail.html';
// Export the multiply with default options (empty array as value)
Sajax\Sajax::export(['multiply' => []]);
// 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>Sajax Multiplier example</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();
Esempio n. 5
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();