It:Upgrading from xajax 0.2 to xajax 0.5
It:Upgrading from xajax 0.2 to xajax 0.5
It:xajax v0.5 beta 1 has been released
This page will, over time, be filled with information showing the changes from v0.2.x to v0.5; many of which are already shown below.
Contents |
[edit] Additions
[edit] Delay Events
You can now assign specific delay events, or 'Loading...' functions to each call (in addition to a global delay event / function); use
xajax.call('functioname',{onRequestDelay:delayFunctionName});
[edit] Plugins
xajax now has a plugin system so it can be extended to work with other frameworks like script.aculo.us. The following is an example of what a plugin call might look like:
xajaxResponse->plugin(‘scriptaculous’)->fade(‘myDiv’);
[edit] Changes
[edit] Request Type
The configuration option for request type has been removed, since most often, POST is used. In addition, the POST method allows for a larger amount of data to be sent along with the request. The GET request method is used as a fallback when the POST request fails.
[edit] Response Commands
xajaxResponse has been refactored to allow future support for other data transport methods. Currently, response commands are stored in an array; the array is converted to XML just before the response is sent. Previously, the XML was built as commands were added to the response, via string concatination.
[edit] Folder Structure
The xajax folder structure has changed to allow seperation of PHP and Javascript files. All PHP files are in xajax_core and all Javascript files are in xajax_js.
[edit] Method Renaming
Please Note: You can use all of the old methods by instanciating new legacyXajax() instead of new xajax() and new legacyXajaxResponse() instead of xajaxResponse().
xajax Methods
xajax->processRequests() has become xajax->processRequest()
All boolean settings such as xajax->debugOn(); and xajax->outputEntitiesOn(); have become xajax->setFlag('debug',true) and xajax->setFlag('outputEntities',true); xajax->setFlags() can also take arrays like xajax->setFlags(array('debug'=>true,'outputEntities'=>true));
xajax->registerExternalFunction() has been integrated with xajax->registerFunction() so that there is now an optional second parameter in xajax->registerFunction() eg xajax->registerFunction('functionName', 'file.php')
xajaxResponse Methods
Most xajaxResponse methods have changed. The confusing 'add' prefix has been removed from most of the functions; so, xajaxResponse->addScript() becomes xajaxResponse->script(), xajaxResponse->addAssign() becomes xajaxResponse->assign(). This makes it fun to chain responses together with PHP5:
$response ->alert("Hi!") ->assign("myDiv", "innerHTML", $stuff) ->plugin('script.aculo.us')->highlight("myDiv") ->scriptCall('finishEditing', $newID);
xajaxResponse->getXML() is gone; just return the xajaxResponse object.
[edit] Quick Reference
| Old Code | New Code |
| require_once('xajax.inc.php'); | require('xajax_core/xajax.inc.php'); |
| xajax->debugOn(); | xajax->setFlag('debug',true); |
| xajax->debugOff(); | xajax->setFlag('debug',false); |
| xajax->statusMessagesOn(); | xajax->setFlag('statusMessages',true); |
| xajax->statusMessagesOff(); | xajax->setFlag('statusMessages',false); |
| xajax->decodeUTF8InputOn(); | setFlag('decodeUTF8Input',true) |
| xajax->registerExternalFunction('function','file.php'); | xajax->registerFunction('function','file.php'); |
| xajax->processRequests(); | xajax->processRequest(); |
| xajaxResponse->loadXML($response); | xajaxResponse->loadCommands($response); |
| return xajaxResponse->getXML(); | return xajaxResponse |
| xajaxResponse->addAssign(); | xajax->assign() |
| xajaxResponse->addAlert(); | xajax->alert() |
| xajaxResponse->addScript(); | xajax->script() |
| xajaxResponse->addScriptCall(); | xajax->call() |
| xajax.loadingFunction = function(){}; | xajax.callback.global.onRequest= function(){}; |
| xajax.doneLoadingFunction = function(){}; | xajax.callback.global.onComplete= function(){}; |
| new function | xajax.callback.global.onFailure = function(args) { |