2014-01-11 82 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( '卓越/測試/指數')>?」