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

Source for file helper_usage.php

Documentation is available at helper_usage.php

  1. <?php
  2. /**
  3.  * Example of Using HTML_AJAX_Helper
  4.  *
  5.  * HTML_AJAX_Helper takes care of basic JavaScript and HTML generation that is needed in many AJAX requests
  6.  *
  7.  * @category   HTML
  8.  * @package    AJAX
  9.  * @author     Joshua Eichorn <josh@bluga.net>
  10.  * @copyright  2005 Joshua Eichorn
  11.  * @license    http://www.opensource.org/licenses/lgpl-license.php  LGPL
  12.  * @version    Release: 0.5.4
  13.  * @link       http://pear.php.net/package/HTML_AJAX
  14.  */
  15.  
  16. // include the helper class
  17. require_once 'HTML/AJAX/Helper.php';
  18.  
  19. // create an instance and set the server url
  20. $ajaxHelper = new HTML_AJAX_Helper();
  21. $ajaxHelper->serverUrl = 'server.php?gzip=true';
  22. $ajaxHelper->jsLibraries['customLib';
  23. ?>
  24. <html>
  25. <head>
  26.  
  27. <?php
  28.     // output a javascript neded to setup HTML_AJAX
  29.     // by default this is all the libraries shipped with HTML_AJAX, take a look at $ajaxHelper->jsLibraries to edit the list
  30.     echo $ajaxHelper->setupAJAX();
  31. ?>
  32.  
  33. </head>
  34. <body>
  35. <?php
  36.     // output a custom loading message
  37.     echo $ajaxHelper->loadingMessage("Waiting on the Server ...");
  38. ?>
  39.  
  40. <div id="updateTarget">I'm an update Target</div>
  41. <?php
  42.     // update the element using ajax
  43.     echo $ajaxHelper->updateElement('updateTarget',array('test','echo_string','Some text to echo'),'replace',true);
  44. ?>
  45.  
  46.  
  47. <p>Was this page loaded using AJAX: <?php var_dump($ajaxHelper->isAJAX())?></p>
  48.  
  49. Below is the output of HTML_AJAX_Helper::isAJAX() on content loaded from AJAX
  50. <div id="updateTarget2"></div>
  51. <?php
  52.     echo $ajaxHelper->updateElement('updateTarget2','support/isajax.php','replace',true);
  53. ?>
  54.  
  55. </body>
  56. </html>
  57. <?php 
  58. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  59. ?>

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