| 
<?php
 require_once "../class.pAjax.php";
 
 
 function multiply($x, $y) {
 return $x * $y;
 }
 
 
 $AJAX = new pAjax;
 $AJAX->disableDomainProtection();
 $AJAX->enableExportProtection();
 $AJAX->export("multiply");
 $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>Server Multiplier</title>
 <?php $AJAX->showJavaScript(".."); ?>
 <script type="text/javascript">
 // Defining Object
 function Multiplier() {
 pAjax.call(this);
 pAjax.setDebugMode(true);
 }
 
 
 // Extending AJAX Object on Multiplier
 var _p = Multiplier.prototype = new pAjax;
 
 
 // Command action: Action that creates and send the request
 _p.execAction = function () {
 var x = document.getElementById("x").value;
 var y = document.getElementById("y").value;
 
 // Creates the request
 var oRequest = this.prepare("multiply", pAjaxRequest.GET);
 oRequest.setParam("value1", x);
 oRequest.setParam("value2", y);
 oRequest.execute(pAjaxRequest.ASYNC); // Same as oRequest.execute();
 }
 
 
 // Callback: Function that handles the response of request
 // Must be called "onLoad".
 _p.onLoad = function () {
 // Retrieve data from response
 // this.getData() is depreciate, backward compatibility still available
 var data = this.getResponse();
 
 document.getElementById("z").value = data;
 }
 
 
 // Creating a simple Multiplier Object
 var Calc = new Multiplier;
 </script>
 </head>
 
 <body>
 <input type="text" name="x" id="x" value="2" size="3"> * <input type="text" name="y" id="y" value="3" size="3">
 = <input type="text" name="z" id="z" value="" size="3">
 
 <input type="button" name="check" value="Calculate" onclick="Calc.execAction(); return false;">
 </body>
 </html>
 
 |