$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


Please Give a perfect solution


You can set ajax response like this:

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


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.