I have a module which creates a front end page which displays winners of particular draw,I want to add a filter by year (winning year) when i change the year it must go by ajax request and change my div
in my display.tpl for the front end i added below javascript
<script type="text/javascript">
{literal}
function QuickLook() {
var year = $("#year").val();
alert(year);
$.ajax({
url: baseDir+'/modules/addwinners/controllers/front/displaybyajax.php',
type: 'get',
data: 'ajax=true&year='+year,
success: function(response) {
alert(response);
console.log('success');
// OTHER SUCCESS COMMAND - CHECK THE RETURN VALUE
document.getElementById("winnersDiv").innerHTML=response;
}
});
return false;
}
{/literal}
but its complaining Fatal error: Class 'ModuleFrontController' not found
You can't access your module controller directly using its full path: /modules/addwinners/controllers/front/displaybyajax.php by accessing your controller this way, the dispatcher is not called and Prestashop Core classes are not loaded.
You need to call your controller the Prestashop way:
<script type="text/javascript">
{literal}
function QuickLook() {
var year = $("#year").val();
alert(year);
$.ajax({
url: baseDir + 'index.php?controller=displaybyajax&redirect=module&module=addwinners',
type: 'get',
data: 'ajax=true&year='+year,
success: function(response) {
alert(response);
console.log('success');
// OTHER SUCCESS COMMAND - CHECK THE RETURN VALUE
document.getElementById("winnersDiv").innerHTML=response;
}
});
return false;
}
{/literal}
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With