0
$myBlock = $this->getLayout()->createBlock('module/admin_productqa_edit'); 

$myHtml =  $myBlock->toHtml(); 
$response['blck'] = $myHtml;

above code work perfect. I need Given below value return as ajax response from controller in magento. How to set ajax response in magento

$this->_addContent($this->getLayout()->createBlock('module/adminhtml_productqa_edit'));
$this->_addLeft($this->getLayout()->createBlock('module/admin_productqa_edit_tabs'));

Please Give a perfect solution

0
1

You can set ajax response like this:

    $response = array(
        'myblock'   => $this->getLayout()->createBlock('module/admin_productqa_edit')->toHtml()
    );

    $this->getResponse()->setBody($response);

You can't use $this->_addContent or $this->_addLeft when doing ajax call because you are not loading entire layout object. You are supposed to process the response and update DOM with javascript.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.