I am trying to call a php function from the backend of a module (I'm using a custom form field). com_ajax
does not work because it pulls the current menu item, which doesn't exist since it is not being called from a menu.
I have tried linking to a php file directly but that will not work because defined('_JEXEC') or die('Direct Access to this location is not allowed.');
is needed for security purposes.
I have also tried using JURI::base() . 'index.php?option=mod_myMod&task=myPhpFunction';
for my AJAX request URL while having the code block below defined before my helper class in the module's helper.php
but just get a 404 (Component not found.)
error:
$taskInput = JFactory::getApplication()->input;
$task = $taskInput->get('task');
if ($task == "importData") {
ModPropertySearchHelper::importDataAjax();
}
I could create a separate component to handle this. However, that just feels weird and is a problem com_ajax
tried to solve, so I would rather not do that.
Is there a way I could override ajax.php
in order to support being called from a module's backend? I wouldn't want to replace it in case of updates and such.
Or is there a better solution to my problem?
index.php?option=com_modules&task=myFunction
....note thecom_modules
as this is the component being usedbasic
module page for my module, but with no form fields or content.