本文介绍了我怎样才能得到通知时,从其他浏览器/计算机数据库更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


**我的问题**而在Facebook,聊天当U收到来自某人的消息,你会得到一个通知,显示具有红色背景的新邮件的数量。所以我的问题是,我们如何能做到让大家免费获赠通知,当数据库被从另一台计算机改变。我用下面的codeS做到了,它工作得很好,但它似乎对处理器有害的,因为它运行mysql查询每一秒。


**My Question **while chatting on Facebook , when u receive a message from someone, you get a notification showing number of new messages with red background.so my question is how we can do so that we recieve a notification when database is changed from another computer.I done it with the following codes and it work well but it seem harmful for processor as it run mysql query each second.

下面的jQuery code

the following jquery code

$(document).ready(
            function() {
                setInterval(function() {
                    $.ajax({
                        url: 'incs/check_new_msg.php' ,
                        cache: false,
                        success: function(data)
                        {
                            $('#orders').html(data);
                        },

                    });
                }, 1000);
            });

在check__new_msg.php我使用的查询从收件箱中选择计数(ID),其中状态='1'然后我赞同它的结果

in check__new_msg.php i use queryselect count(id) from inbox where status = '1'then i echo its result

推荐答案

您正在寻找的反向AJAX 的概念。

You are looking for concept of reverse ajax.

下面是给实现它一个答案:使用PHP反向Ajax实现

Here is one answer given to implement it: Reverse Ajax implementation using php

这篇关于我怎样才能得到通知时,从其他浏览器/计算机数据库更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 21:05