Mini AJAX - make the most of Web 2.0

DokuWiki comes with powerful AJAXian capabilities. This JavaScript plugin makes the handling of AJAX calls to DokuWiki easier. The constructor takes a form and a callback - you just have to do a call() and Mini AJAX does the work ofreading the form fields and so on. When the AJAX Call finishes, the response will be sent back to your callback object. The JavaScript includes basic JSON Functions.

Example

A call looks like:
miniAJAX($('myForm'), myCallback).call();

A sample callback may be:

var shopminiAJAX = {
		/* callerID has to be set */
		callerID: '_ajax_caller_identifier',
 
		/* processResponse has to be set */
		processResponse: function ( data ) {
			var returnData = data.parseJSON();
			alert(returnData);
		}

Finally a corresponding action plugin function:

$controller->register_hook(	'AJAX_CALL_UNKNOWN', 'BEFORE',
				$this, '_my_ajax_functions');
 
function _my_ajax_functions(&$event, $args) {
	if ( $event->data != '_ajax_caller_identifier' ) return;
	require_once( DOKU_INC . 'inc/JSON.php');
	$json = new JSON();
	$_REQUEST = (array)$json->dec($_REQUEST['q']);
 
	header('Content-Type: text/html; charset=utf-8');
	foreach ( $_REQUEST AS $key => $value ) {
		$output .= "$key -> $value\n";
	}
 
	print $json->enc($output);
	return;
}

Download

Version Requirement
2009-04-06 see previous
2008-05-16 current version

Support

If you need help or have suggestions on how to improve this plugin, feel free to contact us.

 

© Copyright 1996 - 2012, i-net software; All Rights Reserved.