Magento Ajax - How to get only body part? -
i trying use ajax call magento. when call block page via ajax, html including head, css, javascript, , body. how body part?
if can provide little more information "block page" calling may easier discern issue. default, magento includes <default>
layout tag pages, give page headers , footers on ajax calls.
to send page without extra, have few options. firstly, can simple set output manually on own, avoiding layout system entirely. magento one-page checkout feature:
$result = array( 'foo' => 'foo', 'bar' => 'bar', ); $this->getresponse()->setbody(zend_json::encode($result));
you can modify method use custom layout handler this:
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)); }
and in layout file:
<your_custom_handle> <remove name="right"/> <remove name="left"/> <block type="module/block" name="root" output="tohtml" template="module/template.phtml"/> </your_custom_handle>
a second option, if want use layouts, define alternative default layout. when call $this->loadlayout();
in magento controllers, can specify handle other <default>
descend from. example magento product controller be:
$this->loadlayout('popup');
this layout defined default within main.xml
layout file, , renders popup.phtml
template, , may suitable use.
if still have trouble, let me know , can try other things. hope helps.
thanks, joe
Comments
Post a Comment