-
Notifications
You must be signed in to change notification settings - Fork 0
/
callScriptTest.php
executable file
·65 lines (55 loc) · 1.64 KB
/
callScriptTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
require("../xajax_core/xajax.inc.php");
function callScript()
{
$response = new xajaxResponse();
$value2 = "this is a string";
$response->call("myJSFunction", "arg1", 9432.12, array("myKey" => "some value", "key2" => $value2));
return $response;
}
function callOtherScript()
{
$response = new xajaxResponse();
$response->call("myOtherJSFunction");
return $response;
}
$xajax = new xajax();
//$xajax->setFlag("debug", true);
$xajax->registerFunction("callScript");
$xajax->registerFunction("callOtherScript");
$xajax->processRequest();
?>
<!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>call Script Test | xajax Tests</title>
<?php $xajax->printJavascript("../") ?>
<script type="text/javascript">
function myJSFunction(firstArg, numberArg, myArrayArg)
{
var newString = firstArg + " and " + (+numberArg + 100) + "\n";
newString += myArrayArg["myKey"] + " | " + myArrayArg.key2;
alert(newString);
xajax.$('myDiv').innerHTML = newString;
}
function myOtherJSFunction() {
var newString = 'No parameters needed for this function.';
alert(newString);
xajax.$('myDiv').innerHTML = newString;
}
</script>
</head>
<body>
<h2><a href="index.php">xajax Tests</a></h2>
<h1>call Script Test</h1>
<p>Howdy.</p>
<p><input type="button" value="Click Me" onclick="xajax_callScript()" /></p>
<p><input type="button" value="or Click Me" onclick="xajax_callOtherScript()" /></p>
<p>Result:</p>
<pre id="myDiv">[blank]</pre>
<p>Expecting:</p>
<pre>arg1 and 9532.12
some value | this is a string</pre>
</body>
</html>