
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.
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; }
| Version | Requirement |
|---|---|
| 2009-04-06 | see previous |
| 2008-05-16 | current version |
If you need help or have suggestions on how to improve this plugin, feel free to contact us.