====== ajaxloader Plugin ====== ---- plugin ---- description: author : Adrian Lang email : dokuwiki@cosmocode.de type : action, ajax lastupdate : 2010-10-06 compatible : depends : conflicts : similar : tags : downloadurl: https://github.com/cosmocode/ajaxloader/zipball/master bugtracker : https://github.com/cosmocode/ajaxloader/issues sourcerepo : https://github.com/cosmocode/ajaxloader/ ---- [[https://www.cosmocode.de/en/open-source/dokuwiki-plugins/|{{ http://cosmocode.de/static/img/dokuwiki/dwplugins.png?recache|A CosmoCode Plugin}}]] ===== Installation ===== Install the plugin using the [[plugin:plugin|Plugin Manager]] and the download URL above, which points to latest version of the plugin. Refer to [[:Plugins]] on how to install plugins manually. ===== Usage ===== The ajaxloader plugin aids in implementing both sides of an AJAX call: Calling and providing the endpoint. You can freely combine both parts with each other or with DokuWiki’s own facilities. ===== Calling ===== The plugin provides two functions: ''doku_ajax(call, params)'' and ''serialize_form(form)''. doku_ajax should be used as a constructor. It expects the name of the ajax call in the format »plugin_PLUGINNAME« or »plugin_PLUGINNAME_CALLNAME«. You may optionally specify a hash with request parameters common to all requests made with this AJAX object. If you provide a form object, it is automatically serialized using ''serialize_form()''. ===== Providing ===== The plugin provides a simpler way of developing the endpoint than hooking ''AJAX_CALL_UNKNOWN'': Just create a file ''ajax.php'' in your plugin directory. If you need multiple endpoints, create a directory ''ajax/'' instead and drop files ''CALLNAME.php'' in it. You may expect the same preprocessing as through ''lib/exe/ajax.php'', only a bit faster. Moreover, if you provide an array called ''$AJAX_JSON'', it is automatically echoed in JSON-encoding afterwards.