I want to call a function in a Helper file, from js file using ajax.

In my config.xml


In js file:


url: "Mage::helper('customname')->getPricesAjaxCall()"
type: "POST",
data: {key: 'value'},
success: function(productId){
    console.log('check 11');

But I don't know what i should put in the url to correctly call it. Any idea?

  • You should use a phtml file to execute js and please echo helper function output. In js file you cannot use PHP methods
    – Kumar M
    Commented Aug 16, 2018 at 14:15

1 Answer 1


This is not possible at all and not as per magento standard flow.

All the HTTP/Ajax request that we make in magento are handled by controller actions using the help of Routers.

Its not possible to directly call the Helper function using Ajax.

You can create one Controller Action that will be called using ajax. In Action function you can call helper function to get data and return directly from function.


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.