Foren / Cotonti / Support / Ajax in Plugins?

GHengeveld
#24844 4. Juni 2010, 08:48
It's really quite simple. You develop the ajax parts as you would when not using Cotonti, with one difference. If you want to use get or post requests through javascript, the URL should look like plug.php?r=plugincode. This will correspond to a file in the root of your plugin folder, which has the hook 'ajax'. I normally name it plugincode.ajax.php.

Basically what the ajax hook does is skip the parsing of the header and footer, so it only outputs the data returned by the plugin itself. Very useful if you want to return JSON or XML.