0
我正在codeigniter中創建一個網站,我想提供以下其他用戶帳戶的功能。如何在特定時間後使用ajax刷新代碼?那麼有人可以給我一些簡單的建議,用ajax做到這一點嗎?試圖讓用戶關注另一個並顯示通知
我正在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代碼在特定時間後檢查數據庫中的條目,以便我可以在屏幕上顯示它。 –
立即查看fgm,f – GYaN
非常感謝您的快速響應。我之前嘗試過setInterval(),但它現在不能工作,現在我的問題已解決。非常感謝你:) –