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

2023-09-11 01:05:05 作者:叼着棒棒糖勇闯天下

我可以添加错误/成功消息Magento管理面板,从服务器端,例如,

 法师:: getSingleton('核心/会话) - > addError('***');
 

但如何显示在客户端使用JS相同的消息?我的意思是标准的方式(当然我可以创建相同的消息框,但它不是一个解决方案)。例如,当我需要显示一些AJAX请求状态。任何想法?

解决方案

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

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

新手在Linux实例上搭建Magento电子商务网站详细教程

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!