Displaying data obtained via AJAX

This is an advanced modification of Add and override language constants plugin. In addition to using language-specific texts, it demonstrates how to retrieve data from server using AJAX requests, and how to display the results in the interface.

Upon downloading and extracting plugin package, rename its main directory from:

plugin-about-i18n-ajax-master

to:

about-i18n-ajax

Then you'll need to deploy the plugin so that its index file is available at the following location:

data/plugins/about-i18n-ajax/index.php

To enable the plugin, add the following to array defined in data/settings/config.php file:

'plugins.about-i18n-ajax' => true, 

In the plugin, hook is added as follows:

$this->AddJsonHook('AjaxPluginGetAjaxData', 'AjaxPluginGetAjaxData');

First parameter matches Action parameter of sendAjaxRequest method call, with Ajax prepended - so the value of Action parameter is actually PluginGetAjaxData here.

Second parameter is hook name defined in plugin's code. This sample plugin retrieve current user's email address as well as product version number, and the latter is displayed in the interface once the AJAX request is processed and response is received. In your actual app, you'll need to modify the plugin to have it connect to your backend or other systems, request the data you require and provide output locations for those.