I want to send block html in JSON response.
To be specific – I want to add functionality where customers are able to edit their addresses via Ajax requests. So the block class will be \Magento\Customer\Block\Address\Edit
instance.
In Magento 1.x it will be just something like that:
$this->getLayout()->createBlock('xxx')->toHtml()
How to achieve similar things in Magento 2 ?
Am I doing it in proper way? Or maybe Magento 2 implements other ways of doing such things?
Best Answer
--
\Magento\Framework\View\LayoutFactory
to create the block.--
\Magento\Framework\Controller\Result\RawFactory
to return Json format.