本文介绍了Magento的:如何在管理面板使用JS来显示标准的错误/成功的消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以添加错误/成功消息Magento管理面板,从服务器端,例如,
法师:: getSingleton('核心/会话) - > addError('***');
但如何显示在客户端使用JS相同的消息?我的意思是标准的方式(当然我可以创建相同的消息框,但它不是一个解决方案)。例如,当我需要显示一些AJAX请求状态。任何想法?
解决方案
函数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!
这篇关于Magento的:如何在管理面板使用JS来显示标准的错误/成功的消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!