weixin_33704234 2013-06-20 10:16 采纳率: 0%
浏览 14

使用Ajax推送通知

I've searched everywhere for this issue, all I found is same problem but with other programming language, so that didn't help me a lot :(

Now I'm using Hibernate, Struts to develop my web site, when an user connect I should display unread messages. I've developed my own solution, but seems to me very costly here it is:

<script type="text/javascript">
    var auto_refresh = setInterval(
    function ()
    {           
        var url = "<%=request.getContextPath()%>"+"/MessagesRecus.do"; 
        jQuery("#messages").load(url).fadeIn("slow");
    }, 400); //Raffraichir chaque 1 seconde
</script>

MessagesRecus.do : is an action that gets unread messages from the DB

I've learned, while I was looking on the other sites, about push notification system. Does anyone have an idea about it? any other suggestion is welcome :) Thank u in advance.

  • 写回答

1条回答 默认 最新

  • weixin_33717298 2013-06-20 10:20
    关注

    I can't tell you a specific system. But currently the best solution I think is to use HTML5 websockets. But there are also javascript libraries that support "Ajax Push" or "Comet", like for example JQuery. I think that should point you on the right track.

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?