Magento: how to show standard error/success message using JS in admin panel?

喜欢而已 提交于 2019-12-06 05:35:06

问题


I can add error/success message to the Magento admin panel from server-side, for example,

Mage::getSingleton(’core/session’)->addError('***');

But how to show the same message on the client-side using JS? I mean standard way (of course I can create the same message box, but it's not a solution). For example when I need to show a status of some AJAX request. Any ideas?


回答1:


function showMessage(txt, type) {
    var html = '<ul class="messages"><li class="'+type+'-msg"><ul><li>' + txt + '</li></ul></li></ul>';
    $('messages').update(html);
}

The type could be 'error', 'success', 'notice' or 'warning'. Enjoy!



来源:https://stackoverflow.com/questions/6042303/magento-how-to-show-standard-error-success-message-using-js-in-admin-panel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!