0

Thanks in advance.

The problem I have is that when I call a controller it gives me a 404 error.

I have already done clear cache, permissions 777 and 644 to folders and disable and activate the created module.

I attach the code in case you see any errors.

config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
        <modules>
                <Mymodule_GeneratePdf>
                        <version>1.0</version>
                </Mymodule_GeneratePdf>
        </modules>
        <frontend>
                <routers>
                        <mymodule_generatePdf>
                                <use>standard</use>
                                <args>
                                        <module>Mymodule_GeneratePdf</module>
                                        <frontName>generatepdf</frontName>
                                </args>
                        </mymodule_generatePdf>
                </routers>
        </frontend>
</config>

controllers/IndexController.php

class Mymodule_GeneratePdf_IndexController extends Mage_Core_Controller_Front_Action
{
    public function PdfAgreementsAction()
    {
        $numDoc = $_POST['numdoc'];
        Mage::log($numDoc);
    }
}

etc/modules/Mymodule_GeneratePdf.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Mymodule_GeneratePdf>
            <active>true</active>
            <codePool>local</codePool>
        </Mymodule_GeneratePdf>
    </modules>
</config>

call by phtml

  function getPdf(num){
    jQuery.ajax({
        url: "<?php echo $this->getUrl('generatepdf/index/PdfAgreements'); // Mage::getUrl('generatepdf/index/PdfAgreements'); ?>",
        type: "POST",
        data: { numdoc: num}
     }).done(function(data) {
console.log(data);
});
}

Thanks.

3
  • Your controller should be inside controllers/ folder not controller/
    – JoshCarter
    Feb 22, 2017 at 8:56
  • folder name at controller should be controllers instead of controller
    – Amit Bera
    Feb 22, 2017 at 8:57
  • Sorry is topographical error the folder is controllers
    – user28804
    Feb 22, 2017 at 9:49

1 Answer 1

0

Please pass form_key in the ajax call

function getPdf(num){
    jQuery.ajax({
        url: "<?php echo $this->getUrl('generatepdf/index/PdfAgreements'); // Mage::getUrl('generatepdf/index/PdfAgreements'); ?>",
        type: "POST",
        data: { numdoc: num, form_key:<?php echo Mage::getSingleton('core/session')->getFormKey() ?>}
     }).done(function(data) {
console.log(data);
});
}

Thanks and let me know if you have any query.

3
  • Added form_key and still giving error 404
    – user28804
    Feb 22, 2017 at 10:08
  • Please try to make pdfAgreements insted of PdfAgreements at all places. Feb 22, 2017 at 10:17
  • Still with the same error
    – user28804
    Feb 22, 2017 at 10:36

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.