cancel
Showing results for 
Search instead for 
Did you mean: 

Update total block using ajax

Update total block using ajax

How to update total blocks in cart page using ajax.
$sidebarCart = $this->getLayout()->getBlock('checkout.cart')->toHtml();
The above code returns empty response.

2 REPLIES

Re: Update total block using ajax

As I understand, you try to call block inside ajax method...

 

let's say you use AjaxController (your own) inside your own module (i.e. OwnModule)

and you try to get $sidebarCart inside method updateAction()

in this case your URL is something like this

 

jQuery.post( '/ownmodule/ajax/update/', ...

 

So, you need to update layout`s xml of this module (or somewhere else)

to appoint your "checkout.cart" for your ajax action, like this

 

<layout>
...
<ownmodule_ajax_update>
  <update handle="checkout_cart_index" />
</ownmodule_ajax_update>
</layout>

In this case you will get your Checkout Cart html-content

 

Re: Update total block using ajax