2014-01-11 83 views
0

我遵循完整的步骤这blog创建模块,但它给我404错误。ajax与magento 404错误

我想从一个.phtml文件,该文件路径如下

web/frontierFinal/app/design/frontend/default/frontier/template/catalog/product/view.phtml 

我创建IndexController.php控制器目录下执行Ajax操作。

/httpdocs/web/frontierFinal/app/code/local/Excellence/Test/controllers 

<?php 
class Excellence_Test_IndexController extends Mage_Core_Controller_Front_Action 
{ 
    public function indexAction() 
    { 
     echo "Hello World"; 
    } 
} 
?> 

当我运行ajax时,它显示404未找到错误。

jQuery.ajax({ 
         url: "<?php echo $this->getUrl('Excellence/test/index') ?>", 
         type: "POST", 
         data: "size=434", 
         success: function(data) { 
         $j('#thankyou').html(data); 
         } 
        }); 
+0

什么,当你去website.com/excellence/test(同website.com/excellence发生/测试/索引)? –

+0

请将/app/code/local/Excellence/Test/etc/config.xml的内容添加到上面的帖子中。你应该有一个前端/路由器块来指定你的控制器的名字。 –

+0

[magento中的ajax无法工作]的可能重复(http://stackoverflow.com/questions/21061663/ajax-in-magento-not-working) – urfusion

回答

0

应用程序/代码/本地/供应商/模块名/控制器/ test.php的 应用程序/代码/本地/ MODULENAME的/ etc/config.xml中

此错误是由于 在你等/ config.xml中

<frontend> 
    <routers> 
     <excellence> 
       <use>standard</use> 
       <args> 
        <module>[vendor]_[modulename]</module> 
        <frontName>excellence</frontName> 
       </args> 
     </excellence> 
    </routers> 
</frontend> 

URL: “的getURL( '卓越/测试/指数')>?”