I'm trying to update a block in my checkout page via ajax. However, when I call the blocks toHtml() function in the controller the code does not continue to execute. Any suggestions? Below is the code in question.
cartController.php:
couponPostAction(){
Mage::log('first step');
....
Mage::log('second step');
$this->loadLayout();
Mage::log('third step');
$totals=$this->getLayout()->getBlock('checkout.cart.totals')->toHtml();
Mage::log('fourth step');
$coupon_code=$this->getLayout()->getBlock('coupon.code')->toHtml();
$response['totals']=$totals;
$response['couponCode']=$coupon_code;
...
$this->getResponse->setBody(Mage::helper('core')->jsonEncode($response));
}
There are also multiple entries of 'coupon.code' in the layout.xml (which I assume the controller somehow knows it's using.. I could be wrong though.).
checkout.xml layout:
<block type="page/html" name="coupon.code" as="couponCode" template="checkout/cart/couponerror.phtml"/>
...
...
<block type="page/html" name="coupon.code" as="couponCode" template="checkout/cart/couponerror.phtml"/>
<block type="checkout/cart_totals" name="checkout.cart.totals" as="totals" template="checkout/cart/totals.phtml"/>
Contents of log:
first step
second step
third step