Magento custom block Ajax in adminhtml
Adding a custom ajax loading block to Magento admin sales order create process
As to not overload the create order process with a lot of AJAX, you can use the already mighty powers Magento comes with.
There is a function defined in sales.js, that allows reloading many blocks at once.
Your container id should be prefixed with “order-“, like
for example. This is required if you want to use order.loadArea(), as it uses a function to get the id of the destination container:
getAreaId : function(area){ return 'order-'+area; },
If you want to output Ajax result messages to the
<div id="order-message">
block, then you can use the ‘adminhtml/session_quote’ for adding messages:
Mage::getSingleton('adminhtml/session_quote')->addSuccess($this->__('Coupon code %s was canceled.', $codeToCancel));
The ‘order-message’ block will always be reloaded when using loadArea, if ‘message’ area is not present, it will push it. If you look into sales.js you will find the following code:
loadAreaResponseHandler : function (response){ ... if(this.loadingAreas.indexOf('message'==-1)) this.loadingAreas.push('message'); ...