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>
Ashish Raj
1,3752 gold badges15 silver badges32 bronze badges
asked Feb 10, 2017 at 11:15
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() Commented Feb 10, 2017 at 11:24
  • var url="<?php echo Mage::getUrl('attributor/controller/getdata'); ?>" please try this Commented Feb 10, 2017 at 11:25
  • seems to be a bit better, but still 404 :( at least url look better :) 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'); ?>"
answered Feb 10, 2017 at 11:36
8
  • 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 ... 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 ;) Commented Feb 10, 2017 at 12:29

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.