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
-
did you check the console what is ajax response?Qaisar Satti– Qaisar Satti2017年02月10日 11:23:21 +00:00Commented Feb 10, 2017 at 11:23
-
responce: 404 :( my module name AMBit, module name Attributor and the method getdata()Rob D. A.– Rob D. A.2017年02月10日 11:24:08 +00:00Commented Feb 10, 2017 at 11:24
-
var url="<?php echo Mage::getUrl('attributor/controller/getdata'); ?>" please try thischin– chin2017年02月10日 11:25:14 +00:00Commented Feb 10, 2017 at 11:25
-
seems to be a bit better, but still 404 :( at least url look better :)Rob D. A.– Rob D. A.2017年02月10日 11:27:47 +00:00Commented Feb 10, 2017 at 11:27
1 Answer 1
try this in ajax Url
var url="<?php echo $this->getUrl('attributor/ajax/getdata'); ?>"
answered Feb 10, 2017 at 11:36
Sanjay Chauhan
3243 silver badges8 bronze badges
-
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.– Rob D. A.2017年02月10日 11:42:29 +00:00Commented Feb 10, 2017 at 11:42
-
You check your controller is called or not using Mage::log()?Sanjay Chauhan– Sanjay Chauhan2017年02月10日 11:56:51 +00:00Commented Feb 10, 2017 at 11:56
-
1check now controller error i think change the controller name.Sanjay Chauhan– Sanjay Chauhan2017年02月10日 12:04:08 +00:00Commented Feb 10, 2017 at 12:04
-
there is controller name error so change your controller name in get url.Sanjay Chauhan– Sanjay Chauhan2017年02月10日 12:05:05 +00:00Commented Feb 10, 2017 at 12:05
-
AAAAAA got it. My bad, wrong path indeed ;)Rob D. A.– Rob D. A.2017年02月10日 12:29:43 +00:00Commented Feb 10, 2017 at 12:29
default