I have created a custom module (test) that has two buttons - a forward and a backward button. When clicked, the Joomla Ajax Interface is used to call the getAjax() function of helper.php. This works just fine, and I get the expected response. The problems appear, when I have multiple instances of the same module.

I have two problems:

  1. The module has a parameter, where you select the categories you want results returned from. I cannot figure out, how to use this parameter in getAjax(), when there is more than one of these modules. In the mod_test.php, I just use $params->get('cat_ids'). That is just not possible in the helper (when there is more than one instance of the module) since JModuleHelper::getModule returns the first module found. Each instance of the module will have different paramters, so it is essential to be able to get these.

  2. This problem is similar. How do I make an Ajax request to a specific instance of a module with Joomla Ajax Interface? Right now, I am using ?option=com_ajax&module=test&format=raw.

  • You should get the module ID and pass this through the Ajax request
    – Lodder
    Commented Jan 30, 2016 at 17:25
  • How and when are there multiple of the same modules which are root cause? When u say multiple you mean on a single web page there might be 2 instances, or do you mean two separate clients looking at the same page produces error? Commented Jan 30, 2016 at 19:46
  • How do you get the module ID without knowing the title of the module? Brian I mean when adding more of the same module to the same page in the Joomla administrator.
    – giano574
    Commented Jan 30, 2016 at 22:17

1 Answer 1


com_ajax dosent need to know correct instance of module, since it only needs to find helper.php (to call getAjax()), which is obviously same for both instances. So this covers your second question.

Change your ajax url to


and you can retrieve it in your getAjax() function to get right instance parameters.

$jinput = JFactory::getApplication()->input;

// Get right instance by title
$module = JModuleHelper::getModule('mod_test', $jinput->getVar('module_title'));
$params = new JRegistry();
  • Thank you. I ended up adding the title of the module as the ID of the containing div and similarly as a part of the button ID's. This way, I get the module title.
    – giano574
    Commented Feb 2, 2016 at 14:14
  • I am having issue to get the right module instance with passing the module_title (module title from $module->title). Instead of the desired current instance, it gets the instance with the lower id - so I can't access the params of the current module. I had to delete all other module instances, in order to make it work. Any ideas?
    – FFrewin
    Commented Mar 30, 2016 at 12:31
  • @FFrewin and your module helper has method getAjax with code similar to my answer?
    – Rene Korss
    Commented Mar 30, 2016 at 15:04
  • Code is similar, but does it (the method) have to be called getAjax()?
    – FFrewin
    Commented Mar 30, 2016 at 17:40
  • @FFrewin no it dosen't have to be getAjax. But then your url should contain &method=custom, which results in calling customAjax method. As you can see, it has to end with Ajax. By default method value is get, resulting in calling getAjax.
    – Rene Korss
    Commented Mar 30, 2016 at 18:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.