I have no experience with Ajax and little to no experience with Joomla. I've managed to create my own Joomla modules with no problem. Today I tried to use Ajax in one of my modules but I am getting an error: "Method getAjax does not exist."
.
Here is my helper.php
<?php
class ModDisplayVacancies
{
public static function getAjax()
{
return "getAjax return";
}
....
}
my mod_display_vacancies.php
<?php
// No direct access
defined('_JEXEC') or die;
// Include the syndicate functions only once
$document = JFactory::getDocument();
require_once dirname(__FILE__) . '/helper.php';
$document->addStyleSheet('/Joomla/modules/mod_display_vacancies/css/styles.css');
$document->addScript('/Joomla/modules/mod_display_vacancies/js/custom.js');
$table = ModDisplayVacancies::createTable($params);
require JModuleHelper::getLayoutPath('mod_display_vacancies');
And my JavaScript:
jQuery(document).on('click', 'button[id=vacancies_next]', function(){
console.log("next");
var request = {
'option' : 'com_ajax',
'module' : 'display_vacancies',
'data' : 5,
'format': 'json'
}
jQuery.ajax({
type: 'GET',
data: request,
success:function(responce){
console.log("success");
console.log(responce);
},
error:function(responce){
console.log("error");
console.log(responce);
}
});
});
It's pretty strange to me why in the console I'm getting "success" and then an error: