DEPRECATION WARNING

This documentation is not using the current rendering mechanism and is probably outdated. The extension maintainer should switch to the new system. Details on how to use the rendering mechanism can be found here.

EXT: xajax library

Author:Kasper Skårhøj
Created:2002-11-01T00:32:00
Changed:2009-12-18T07:33:22.500000000
Classification:gg_xajax
Description:The keywords help with categorizing and tagging of the manuals. You can combine two or more keywords and add additional keywords yourself. Please use at least one keyword from both lists. If your manual is NOT in english, see next tab "language" ---- forEditors (use this for editors / german "Redakteure") forAdmins (use this for Administrators) forDevelopers (use this for Developers) forBeginners (manuals covering TYPO3 basics) forIntermediates (manuals going into more depth) forAdvanced (covering the most advanced TYPO3 topics) see more: http://wiki.typo3.org/doc_template#tags ----
Keywords:forDevelopers, xajax, library
Author:Marco Malagoli
Email:marco@gasser-gasser.ch
Info 4:
Language:en

img-1 img-2 EXT: xajax library - gg_xajax

EXT: xajax library

Extension Key: gg_xajax

Language: en

Keywords: forDevelopers, xajax, library

Copyright 2008-2009 by Joseph Woolley, Steffen Konerow, Jared White & J. Max WilsonCopyright 2005-2007 by Jared White & J. Max Wilson

This document is published under the Open Content License

available from http://www.opencontent.org/opl.shtml

The content of this document is related to TYPO3

- a GNU/GPL CMS/Framework available from www.typo3.org

Table of Contents

EXT: xajax library 1

`Introduction 3 <#1.1.Introduction|outline>`_

What does it do ? 3

`Tutorial 4 <#1.2.Tutorial|outline>`_

`Online documentation 5 <#1.3.Online%20documentation|outline>`_

`Known problems 6 <#1.4.Known%20problems|outline>`_

`ChangeLog 7 <#1.5.ChangeLog|outline>`_

Introduction

What does it do ?

xajax is an open source PHP class library implementation of AJAX that allows developers to create web-based Ajax applications using HTML, CSS, JavaScript, and PHP. Applications developed with xajax can asynchronously call server-side PHP functions and update content without reloading the page.

Xajax is copyright by Jared White, J. Max Wilson, Joseph Woolley & Steffen Konerow.

Xajax is released under the terms of the BSD license.

Tutorial

Xajax is designed to be extremely easy to implement :

  1. Include in your extension the xajax class library
require_once (t3lib_extMgm::extPath('gg_xajax') . 'xajax_core/xajax.inc.php');
  1. Instantiate the xajax object
$this->xajax = t3lib_div::makeInstance ('xajax');

3. Configure xajax (see xajax website for a complete list of the available configuration settings)

$this->xajax->configure('wrapperPrefix',$this->prefixId);
$this->xajax->configure('characterEncoding','utf-8');
$this->xajax->configure('decodeUTF8Input',true);

4. Register the names of the PHP functions you want to be able to call through ajax

$this->xajax->register(XAJAX_FUNCTION,array('myFunction', &$this, 'myFunction'));

5. Write the PHP functions you have registered and use the xajaxResponse object to return XML commands from them

function myFunction($data) {
     // do some stuff based on $data like query data from a database and put it into
           // a variable like $newContent
           $newContent = 'value of data: ' . $data;

           // instantiate the xajaxResponse object
           $objResponse = t3lib_div::makeInstance ('xajaxResponse');

           // add a command to the response to assign the innerHTML attribute of the element with
           // id=”someElementId” to whatever the new content is
           $objResponse->assign('someElementId','innerHTML',$newContent);

           // return the xajaxResponse object
           return $objResponse;
}

6. Before your script sends any output, have xajax handle any requests:

$this->xajax->processRequest();
  1. Include the necessary JavaScript:
$GLOBALS['TSFE']->additionalHeaderData[$this->prefixId] = $this->xajax->getJavascript (t3lib_extMgm::siteRelPath('gg_xajax'));

8. Call the function from a JavaScript event or function in your extension

<a href="javascript:void(0);" onclick="'.$this->prefixId.'myFunction('.$params.');">xajax test</a>

That's it. xajax takes care of most everything else. Your biggest task is writing the PHP functions and returning xajax XML responses from them-- which is made extremely easy by the xajaxResponse class.

Online documentation

Online documentation for this class is available on the xajax website at http://xajaxproject.org

Known problems

None yet. Please tell me if you find something.

ChangeLog

See the Changelog file inside extension

7