久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 Magento 中使用基本的 AJAX 調(diào)用

Using Basic AJAX calls within Magento(在 Magento 中使用基本的 AJAX 調(diào)用)
本文介紹了在 Magento 中使用基本的 AJAX 調(diào)用的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我正在編寫一個模塊來在 Magento 中執(zhí)行一個簡單的 Ajax 調(diào)用,但到目前為止我無法讓它工作 - 我覺得我在某處缺少一個重要的組件.這些是我目前擁有的文件:

I'm writing a module to carry out a simple Ajax call in Magento, but I'm unable to get it work thus far - I feel like I'm missing a vital component somewhere. These are the files I currently have:

Creare/Groupedajax/controllers/AjaxController.php:

class Creare_Groupedajax_AjaxController extends Mage_Core_Controller_Front_Action {

    public function indexAction() {
        $this->loadLayout();
        $this->renderLayout();
    }
}

Creare/Groupedajax/etc/config.xml:

<?xml version="1.0"?>
<config>
  <modules>
    <Creare_Groupedajax>
      <version>0.1.0</version>
    </Creare_Groupedajax>
  </modules>
  <frontend>
    <routers>
      <groupedajax>
        <use>standard</use>
        <args>
          <module>Creare_Groupedajax</module>
          <frontName>groupedajax</frontName>
        </args>
      </groupedajax>
    </routers>
    <layout>
      <updates>
        <groupedajax>
          <file>groupedajax.xml</file>
        </groupedajax>
      </updates>
    </layout>
  </frontend>
</config>

我的 Ajax 調(diào)用:

$j.post("groupedajax/ajax/index", { size: $j(this).val()}, function(data) {
        $j('#results').html(data);
    });

layout/groupedajax.xml:

<?xml version="1.0"?>
<layout version="1.0">
  <groupedajax_ajax_index>
    <block type="groupedajax/groupedajax" name="root" output="toHtml" template="groupedajax/groupedajax.phtml" />
  </groupedajax_ajax_index>
</layout>

我的 .phtml 文件目前只有測試".我只需要我的結(jié)果 div 返回測試"值.我只是想知道是否所有的位都到位以使其正常工作?

My .phtml file simply has 'test' in it at the moment. I just need my results div to return the 'test' value. I just want to know if all the bits are in place for this to work?

這是我遵循的教程:http://www.atwix.com/magento/ajax-requests-in-magento/

======================== 已解決 ==========================

我只需要在我的網(wǎng)址開頭加一個正斜杠:

I just needed a forward slash at the beginning of my url:

$j.ajax({
        url: "/groupedajax/ajax/index",
        type: "POST",
        data: "size="+$j(this).val(),
        success: function(data) {
        $j('#results').html(data);
        }
    });

推薦答案

如果您的 javascript 是從 .phtml 模板文件輸出的,那么您可以使用 一個方便的函數(shù),使 URL 完全合格,這將是最安全的處理方式.

If your javascript is being output from a .phtml template file then you can use a convenience function to make the URL fully-qualified which will then be the safest way to proceed.

$j.ajax({
    url: "<?php echo $this->getUrl('groupedajax/ajax/index') ?>",
    type: "POST",
    data: "size="+$j(this).val(),
    success: function(data) {
    $j('#results').html(data);
    }
});

這篇關(guān)于在 Magento 中使用基本的 AJAX 調(diào)用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Override Magento Config(覆蓋 Magento 配置)
What would cause a print_r and/or a var_dump to fail debugging a variable?(什么會導(dǎo)致 print_r 和/或 var_dump 調(diào)試變量失敗?)
How to update custom options programatically in magento?(如何在 magento 中以編程方式更新自定義選項?)
Magento 404 on Admin Page(管理頁面上的 Magento 404)
Magento - get price rules from order(Magento - 從訂單中獲取價格規(guī)則)
Magento Change Product Page Titles to Include Attributes(Magento 更改產(chǎn)品頁面標(biāo)題以包含屬性)
主站蜘蛛池模板: 一区二区三区在线电影 | 99国内精品久久久久久久 | 欧美成人综合 | 91资源在线播放 | 国产精品久久久久久久久久尿 | 欧美成人自拍 | 国产精品成人品 | 男女污污动态图 | av在线播放网址 | 日韩在线不卡视频 | ww 255hh 在线观看 | 国产一区欧美 | 欧美精品乱码久久久久久按摩 | 色欧美片视频在线观看 | 懂色av一区二区三区在线播放 | www.久久影视 | 亚洲精品在线看 | 久久综合伊人 | 黄免费观看视频 | 另类视频在线 | 久久综合久久久 | 91网在线观看 | 日韩黄a| 波多野结衣中文字幕一区二区三区 | 午夜小视频在线观看 | 嫩草视频入口 | 亚洲网站在线观看 | 中文字幕在线观看视频网站 | 欧美精品1区2区 | 国产亚洲成av人在线观看导航 | 亚洲 欧美 日韩 精品 | 污视频免费在线观看 | 高清一区二区三区 | 欧美成人精品一区二区三区 | 精品一区二区三区在线观看国产 | av高清| 一区二区不卡 | 日本人和亚洲人zjzjhd | 国产成人免费视频网站高清观看视频 | 国产精品免费一区二区三区四区 | 九九在线精品视频 |