2017-03-18 21 views

回答

0

您可以創建表格通知。當用戶跟隨​​另一個用戶時。您在通知表中添加數據。表結構如下

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 
     }, 
    }); 
} 
+0

謝謝您的回答我真的很感激。但是,你可以給一些Ajax代碼在特定時間後檢查數據庫中的條目,以便我可以在屏幕上顯示它。 –

+0

立即查看fgm,f – GYaN

+0

非常感謝您的快速響應。我之前嘗試過setInterval(),但它現在不能工作,現在我的問題已解決。非常感謝你:) –

相關問題