AJAX
[ class tree: AJAX ] [ index: AJAX ] [ all elements ]

Source for file server.php

Documentation is available at server.php

  1. <?php
  2. /**
  3.  * Simplest possible usage of HTML_AJAX_Server
  4.  *
  5.  * The server responds to ajax calls and also serves the js client libraries, so they can be used directly from the PEAR data dir
  6.  * 304 not modified headers are used when server client libraries so they will be cached on the browser reducing overhead
  7.  *
  8.  * @category   HTML
  9.  * @package    AJAX
  10.  * @author     Joshua Eichorn <josh@bluga.net>
  11.  * @copyright  2005 Joshua Eichorn
  12.  * @license    http://www.opensource.org/licenses/lgpl-license.php  LGPL
  13.  * @version    Release: 0.5.4
  14.  * @link       http://pear.php.net/package/HTML_AJAX
  15.  */
  16.  
  17.  // include the server class
  18. include 'HTML/AJAX/Server.php';
  19.  
  20. // include the test class will be registering
  21.     include 'support/test.class.php';
  22.  
  23. // create our new server
  24. $server = new HTML_AJAX_Server();
  25.  
  26. // register an instance of the class were registering
  27. $test =new test();
  28. $server->registerClass($test);
  29. $server->ajax->packJavaScript = true;
  30.  
  31. if (isset($_GET['gzip']&& $_GET['gzip'== 'true'{
  32.     $server->compression['enabled'= true;
  33. }
  34.  
  35. // user HTML_AJAX to deliver a custom library
  36. $server->registerJSLibrary('customLib','customLib.js','./support/');
  37.  
  38. // handle different types of requests possiblities are
  39. // ?client=all - request for all javascript client files
  40. // ?stub=classname - request for proxy stub for given class, can be combined with client but this may hurt caching unless stub=all is used
  41. // ?c=classname&m=method - an ajax call, server handles serialization and handing things off to the proper method then returning the results
  42. $server->handleRequest();
  43. ?>

Documentation generated on Fri, 04 Apr 2008 18:30:26 -0400 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.