scriptCallTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. require("../xajax.inc.php");
  3. function callScript()
  4. {
  5. $response = new xajaxResponse();
  6. $value2 = "this is a string";
  7. $response->addScriptCall("myJSFunction", "arg1", 9432.12, array("myKey" => "some value", "key2" => $value2));
  8. return $response;
  9. }
  10. $xajax = new xajax();
  11. //$xajax->debugOn();
  12. $xajax->registerFunction("callScript");
  13. $xajax->processRequests();
  14. ?>
  15. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  16. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  17. <html xmlns="http://www.w3.org/1999/xhtml">
  18. <head>
  19. <title>addScriptCall Test | xajax Tests</title>
  20. <?php $xajax->printJavascript("../") ?>
  21. <script type="text/javascript">
  22. function myJSFunction(firstArg, numberArg, myArrayArg)
  23. {
  24. var newString = firstArg + " and " + (+numberArg + 100) + "\n";
  25. newString += myArrayArg["myKey"] + " | " + myArrayArg.key2;
  26. alert(newString);
  27. xajax.$('myDiv').innerHTML = newString;
  28. }
  29. </script>
  30. </head>
  31. <body>
  32. <h2><a href="index.php">xajax Tests</a></h2>
  33. <h1>addScriptCall Test</h1>
  34. <p>Howdy. <input type="button" value="Click Me" onclick="xajax_callScript()" /></p>
  35. <p>Result:</p>
  36. <pre id="myDiv">[blank]</pre>
  37. <p>Expecting:</p>
  38. <pre>arg1 and 9532.12
  39. some value | this is a string</pre>
  40. </body>
  41. </html>