Craft CMS Asked on June 6, 2021
I have a simple controller in /craft/plugins/craft-dns-notifier/src/conrollers/DnsNotifierController:
namespace kokesjandnsnotifiercontrollers;
use craftwebController;
class DnsNotifierController_DbController extends Controller
{
public function buu() {
echo "tradada";
}
}
I would like to access the buu() action from src/templates/index.html twig file via Ajax.
I’ve had no luck for three days, unable to find any hint anywhere. Nothing I have tried worked. It seems like very easy task to me, but I just can’t make it work.
I'd suggest generating the code via pluginfactory.io and if you have code comments enabled, it'll give you the URI that you need to trigger your action in the example code.
But essentially it's going to be a kebab-case version of your controller route, with a kebab-case version of your method name (but removing the action preface).
For you, first you should rename your method thusly:
public function actionBuu() {
echo "tradada";
}
And then your URI would be something like:
/actions/dns-notifier/dns-notifier-controller-db-controller/buu
See here for more on controller actions
Answered by andrew.welch on June 6, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP