I followed this guide step by step and I've just created a plugin that should elaborate AJAX calls received from a form in the front-end, so that the data sent by every user will be structured and manipulated on the back-end before sending an email to everyone of them. The forn is written in HTML, CSS and pure Javascript, meaning that it's been constructed out of the Joomla framework. My Joomla version is the 3.10.11 .
So, I created 3 files:
- formplugin.php
- formplugin.xml
- index.html
Eventually I've installed the plugin and everything seemed to be alright.
First file content is the following one:
<?php
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Plugin\CMSPlugin;
jimport('joomla.plugin.plugin');
class plgAjaxFormplugin extends JPlugin {
protected $app;
protected $autoloadLanguage = true;
public function onAjaxFormplugin() {
var_dump("prova");
return "prova";
}
}
?>
"formplugin.xml" is constructed like this:
<?xml version="1.0" encoding="utf-8"?>
<extension type="plugin" group="ajax" method="upgrade">
<name>formplugin</name>
<author>Autore</author>
<creationDate>Apr 2023</creationDate>
<license>MIT</license>
<authorEmail>[email protected]</authorEmail>
<authorUrl>www.sitoweb.it</authorUrl>
<version>0.01</version>
<description>FORMPLUGIN_XML_DESCRIPTION</description>
<files>
<filename plugin="formplugin">formplugin.php</filename>
<filename>index.html</filename>
</files>
</extension>
"index.html" contains the classic single row:
<!DOCTYPE html><html></html>
On the client side I am temporarily trying to send HTTP GET requests with Postman, with this URL:
http://localhost/joomla_3-10/index.php?option=com_ajax&plugin=formplugin&format=raw
Every request seem to be successful, I get the 200
code. The problem is that no response is given, anyhow. It's like the "onAjaxFormplugin" function is not even called.
What could the origin of this problem be?