Php 试图让用户跟随另一个并显示通知

Php 试图让用户跟随另一个并显示通知,php,jquery,ajax,Php,Jquery,Ajax,我正在用codeigniter创建一个网站,我想提供一个跟踪其他用户帐户的功能。在指定的时间之后,如何使用ajax刷新代码?有人能给我一些简单的建议来使用ajax吗?您可以创建一个表通知。当一个用户后面跟着另一个用户时。您可以在通知表中添加数据。表结构如下所示 id int image text if you need to show image with notification. titl

我正在用codeigniter创建一个网站,我想提供一个跟踪其他用户帐户的功能。在指定的时间之后,如何使用ajax刷新代码?有人能给我一些简单的建议来使用ajax吗?

您可以创建一个表通知。当一个用户后面跟着另一个用户时。您可以在通知表中添加数据。表结构如下所示

id                       int
image                    text            if you need to show image with notification.
title                    text            Eg. Ram followed you.
link                     text            Link on which you want to redirect.
notification_for         text            user_id of user (sometimes notification is for multiple users)
login_type               text            I use this table for admin/front panel. So I've to use this
created_date             datetime        
created_by               int
updated_date             datetime
updated_by               int
status                   int
jQuery代码

$(document).ready(function(e){ getnotification();});

function getnotification(){
    $.ajax({
        url         : path/to/post,
        type        : 'POST',
        data        : {'id':id},
        success     : function(e) {
            window.setInterval(function(){getnotification();}, 5000);//run after 5 seconds
        },
    });
}

谢谢你的回答,我真的很感激。但是你能给我一些ajax代码,在特定时间后检查数据库中的条目,这样我就可以在屏幕上显示它了。我以前尝试过setInterval(),但现在问题解决了,它不起作用。非常感谢:)没关系。。。。。。