Magento Ajax – 如何获得身体部位?
发布时间:2020-12-16 03:06:57 所属栏目:百科 来源:网络整理
导读:我试图用Magento使用ajax调用.当我通过Ajax调用一个页面时,我会得到所有的HTML,包括head,css,javascript和body.如何才能获得身体的一部分? 如果您可以提供更多有关您所呼吁的“阻止页面”的信息,可能会更容易辨别问题.默认情况下,Magento包括 default所有页
我试图用Magento使用ajax调用.当我通过Ajax调用一个页面时,我会得到所有的HTML,包括head,css,javascript和body.如何才能获得身体的一部分?
如果您可以提供更多有关您所呼吁的“阻止页面”的信息,可能会更容易辨别问题.默认情况下,Magento包括< default>所有页面的布局标签,即使在AJAX调用中也能为您提供页眉和页脚.
要发送一个没有额外的页面,你有几个选择.首先,您可以简单地自己设置输出,避免布局系统完全. Magento为单页结帐功能执行此操作: $result = array( 'foo' => 'foo','bar' => 'bar',); $this->getResponse()->setBody(Zend_Json::encode($result)); 您也可以修改此方法以使用自定义布局处理程序,如下所示: protected function loadPage() { $layout = $this->getLayout(); $update = $layout->getUpdate(); $update->load('your_custom_handle'); $layout->generateXml(); $layout->generateBlocks(); $output = $layout->getOutput(); $result = array( 'outputHtml' => $output,'otherVar' => 'foo',); $this->getResponse()->setBody(Zend_Json::encode($result)); } 在你的布局文件中: <your_custom_handle> <remove name="right"/> <remove name="left"/> <block type="module/block" name="root" output="toHtml" template="module/template.phtml"/> </your_custom_handle> 第二个选项,如果要使用布局,则是定义备用的默认布局.当你调用$this-> loadLayout();在Magento控制器中,您可以实际指定< default>以外的句柄.从下降. Magento产品控制器的一个例子是: $this->loadLayout('popup'); 该布局默认在main.xml布局文件中定义,并呈现popup.phtml模板,可能适合您使用. 如果你还是有麻烦的话,让我知道,我们可以尝试其他的事情.希望有帮助. 谢谢,乔 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |