I'm using an ajax call that hits the immediate function fine, and then returns a dummy value via dump(). However, when I change it to call another function and get my data rather than using the dummy value, I'm getting a 500 error.

In Helper.php, This returns the value with a code 200:

public static function getStoresByZipAjax(){

    $input = JFactory::getApplication()->input;
    $zip  = $input->get("zip");


    //return $this->getStores($zip);

However, when I comment out the dump and reinstate the function call, it fails with a 500:

public static function getStoresByZipAjax(){

    $input = JFactory::getApplication()->input;
    $zip  = $input->get("zip");


     return $this->getStores($zip);

public static function getStores($zip){
    $test = $zip;


Here is my mod_hunter_maps_dev.php file:

 //check joomla calling
defined('_JEXEC') or die;
require_once dirname(__FILE__) . '/helper.php';

$test = modHunterMapsDevHelper::getStores();

require JModuleHelper::getLayoutPath('mod_hunter_maps_dev', $params->get('layout', 'default'));

What am I doing wrong here?

AJAX call for reference:

   type: 'GET',
   url: "<?php echo JURI::base() . "index.php?option=com_ajax&module=hunter_maps_dev&method=getStoresByZip&zip="?>"  +zip+ "&format=json",
   error: function(xhr, status, error) {

1 Answer 1


The fatal error will be: "PHP Fatal error: Using $this when not in object context"

You need to change

return $this->getStores($zip);


return self::getStores($zip);
  • Yes, that was the issue. Thanks!
    – Geoff_S
    Sep 24, 2021 at 14:10

Your Answer

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

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