Question

I have created a custom front end module that allows a user to go through a wizard like process. I would like to make this AJAX.

I am loading my layout block with the following

<batch_index_index>
    <reference name="content">
        <block type="batch/batch" name="batch" template="batch/batch.phtml"/>
    </reference>
</batch_index_index>

However the default template is being returned with that phtml file, how do I get magento to return just the contents of the phtml file?

Was it helpful?

Solution

try this:

<batch_index_index>
    <block type="batch/batch" name="root" template="batch/batch.phtml"/>
</batch_index_index>

OTHER TIPS

Here's one module on Github which helps developer to work on Magento, with Ajax. It is also available on Magento Connect.

The alternative is, that you generate the block in the controller:

$block = $this->getLayout()->createBlock($name);
$this->getResponse()->setBody(json_encode($block->toHtml()));

edit added json_encode as suggested from @sparcksoft

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top