0

My AjaxController

class AMBit_Product_AjaxController extends Mage_Core_Controller_Front_Action{

        public function getdataAction(){

            echo 'PRODUCTS IN THIS CATEGORY';
            echo 'temporarily removed content ....';


        }
}

and the code:

jQuery(document).ready(function(){

    jQuery('.level1').on('mouseover',function(){

        var url="<?php Mage::getUrl('attributor/controller/getdata'); ?>";

        var catName = jQuery(this).find('span').text();

        console.log(url);

        jQuery('#prod').html(catName);

        jQuery.ajax({
            url: url,

            type: "POST",

            dataType: "JSON",

            data: catName,

            success: function(result){
                    jQuery("#prod").html(result,function(){
                        alert(result);
                        die();
                    });
            },
            error: function(result){
                console.log('no response !');
                },
        })
    })
 })

and "No response" ... What am I doing wrong ?

UPDATE (controller bit):

<frontend>
  <routers>
        <attributor>
          <use>standard</use>
          <args>
             <module>AMBit_Attributor</module>
             <frontName>attributor</frontName>
          </args>
        </attributor>
  </routers>
</frontend>
4
  • did you check the console what is ajax response? Commented Feb 10, 2017 at 11:23
  • responce: 404 :( my module name AMBit, module name Attributor and the method getdata()
    – Rob D. A.
    Commented Feb 10, 2017 at 11:24
  • var url="<?php echo Mage::getUrl('attributor/controller/getdata'); ?>" please try this
    – chin
    Commented Feb 10, 2017 at 11:25
  • seems to be a bit better, but still 404 :( at least url look better :)
    – Rob D. A.
    Commented Feb 10, 2017 at 11:27

1 Answer 1

1

try this in ajax Url

var url="<?php echo $this->getUrl('attributor/ajax/getdata'); ?>"
9
  • Same as this: var url="<?php echo Mage::getUrl('attributor/controller/getdata'); ?>". Returning the same url but it seem like it won't execute/find controller ...
    – Rob D. A.
    Commented Feb 10, 2017 at 11:42
  • You check your controller is called or not using Mage::log()? Commented Feb 10, 2017 at 11:56
  • 1
    check now controller error i think change the controller name. Commented Feb 10, 2017 at 12:04
  • there is controller name error so change your controller name in get url. Commented Feb 10, 2017 at 12:05
  • AAAAAA got it. My bad, wrong path indeed ;)
    – Rob D. A.
    Commented Feb 10, 2017 at 12:29

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.