且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Magento的:如何在管理面板使用JS来显示标准的错误/成功的消息?

更新时间:2023-11-29 23:29:22

 函数showMessage(TXT,类型){
    VAR HTML ='< UL类=消息><李类=+类型+' - 味精>< UL><李> + TXT +'< /李>< / UL>< /李>< / UL>';
    $('消息'),更新(HTML)。
}
 

键入的可能是'错误','成功',通知或警告。尽情享受吧!

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?

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!