Coldfusion - 数据库记录更新时刷新页面

Coldfusion - Refreshing Page When A Database Record Updates

美好的一天,

让我描述一下我的问题:

场景:

问题:

解决方案:

可以通过 sockets 完成,您不必每分钟检查一次新记录的可用性。

你也可以用 javascript/jquery:

<script>
var lastAlert = '#lastAlert#'; //last at the time of loading the page

setInterval(function() {
    lastAlert = isUpdated(lastAlert);
}, 60000);

function isUpdated(lastAlert){
res = lastAlert;
$.ajax({                            
    url: 'checkAlerts.cfm', //in this file do check for changes in the database. should return the number of the last alert
    type: 'POST',
    data: {lastAlert:lastAlert},
    cache: false,
    success:function(res){  
        if(res > lastAlert){
            //your code if there is a new entry 
            alert('a new entry has been added');
        }
    }
});
return res;
}   
</script>

我没有检查代码!但我希望你明白如何进行。