阳光不锈

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: :: :: 管理 ::

I created a web application which required to keep the session with the Domino server active. The current server settings is only 30 minutes. Changing that is not an option because it will effect other applications. A solution is to always do a server request before the session time ends. A very easy way to do it is to use prototype.js PeriodicalExecuter. You can specify the number of seconds when should a function be triggered

new PeriodicalExecuter(KeepSessionAlive, 1200);

function KeepSessionAlive ( ) {
var ajax = new Ajax.Request("/icons/blank.gif",{
method:"get"
});
}


Every 20 minutes (1200 seconds) I call the function KeepSessionAlive. The function will make a simple request to the blank.gif icon on the server. This will keep the session with the server alive. You can use this function to refresh and update a view every few minutes. This is another one of the simple useful function provided by prototype.js.

********************************************************************************************************************************

 

posted on 2009-05-15 14:46  靳小透  阅读(529)  评论(0编辑  收藏  举报