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");
dump($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");
//dump($zip);
return $this->getStores($zip);
}
public static function getStores($zip){
$test = $zip;
dump($test);
}
Here is my mod_hunter_maps_dev.php file:
<?php
//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:
jQuery.ajax({
type: 'GET',
url: "<?php echo JURI::base() . "index.php?option=com_ajax&module=hunter_maps_dev&method=getStoresByZip&zip="?>" +zip+ "&format=json",
success:function(data){
console.log('success');
},
error: function(xhr, status, error) {
alert(xhr.responseText);
}
});