0

I have created custom module for store credits, for this I have used ajax which are working at frontend but when calling adminhtml controller using ajax at admin it returns 404 not found error.

My config.xml is here :

<?xml version="1.0"?>
<config>
    <modules>
        <Assel_Customajax>
            <version>0.9.0</version>
        </Assel_Customajax>
    </modules>
    ...
    <frontend>
        <routers>
            <checkout>
                <args>
                    <modules>
                        <Assel_Customajax before='Mage_Checkout'>Assel_Customajax_Checkout</Assel_Customajax>
                    </modules>
                </args>
            </checkout>
        </routers>
    </frontend>
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <Assel_Customajax before="Mage_Adminhtml">Assel_Customajax_Adminhtml</Assel_Customajax>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
   ...
</config>

Ajax for calling controller at admin

new Ajax.Request("<?php echo Mage::getUrl('assel_customajax/adminhtml_credits/usecredits') ?>", 
{
    method: 'post',
    onComplete: function(result) 
    {
        ...
    }
});  

I have created function in customajax/controllers/adminhtml/creditscontroller :

public function usecreditsAction()
{
   ...
}

But ajax return 404 not fount error. How to call controller function successfully?

  • Quite a few syntax errors here which might be why you are not getting many replies, i.e. the url you are generating is wrong, you are not using the adminhtml helper to generate admin urls, controller name should be camelcase. Check through everything, correct and you will probably find things to work. – Jonathan Hussey Dec 8 '15 at 11:04
  • Have you check error log when you try Ajax. Is there any things it show. – Dhiren Vasoya Feb 19 '17 at 8:40
1

Try this

<admin>
   <routers>
      <adminhtml>
         <args>
            <modules>
               <Assel_Customajax before="Mage_Adminhtml">Assel_Customajax</Assel_Customajax>
            </modules>
         </args>
      </adminhtml>
   </routers>
</admin>

EDIT

new Ajax.Request("<?php echo Mage::getUrl('adminhtml/assel_customajax/adminhtml_credits/usecredits') ?>", 
{
    method: 'post',
    onComplete: function(result) 
    {
        ...
    }
}); 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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