1

I am trying to call the custom modules controller function for ajax call, Can any tell me how to get the URL. This is my controller function,

class Spritz_RequestQuotation_IndexController extends Mage_Core_Controller_Front_Action
{
   public function emailquoteAction(){

   }
}

This code I am using to get URL, Its giving 404 not found.

<?php echo $this->getUrl('spritz_requestquotation/IndexController/emailquote') ?>

This is my JS code.

var formId = 'quotation_form';
var myForm = new VarienForm(formId, true);
var postUrl = '<?php echo $this->getUrl('spritz_requestquotation/IndexController/emailquote') ?>';
function doAjax() {
    if (myForm.validator.validate()) {
        new Ajax.Updater(
            { success:'formSuccess' }, postUrl, {
                    method:'post',
                    asynchronous:true,
                    evalScripts:false,
                    onComplete:function(request, json) {
                    Element.hide(formId);
                    Element.show('formSuccess');
                    setTimeout(function(){ 
                        var inst = jQuery('[data-remodal-id=quoteform]').remodal();
            inst.close();
                    }, 2000);
                },
                onLoading:function(request, json){
                    Element.show('formLoader');
                },
                parameters: $(formId).serialize(true),
            }
        );
    }
}

new Event.observe(formId, 'submit', function(e){
    e.stop();
    doAjax();
});
3
  • upload your js code also. Dec 3, 2018 at 5:41
  • Hi, I have updated my js code. please check. Dec 3, 2018 at 5:44
  • Is it working for you? Dec 3, 2018 at 5:51

1 Answer 1

2

You need to change from IndexController to index. Like this:

<?php echo $this->getUrl('spritz_requestquotation/index/emailquote') ?>
2

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.