dwr反推技术的一个问题

The reverse ajax poll can start before the scriptSessionId is created. This can result in 2 scriptSessions being created for a single page.

If the following happens on page load:
1. include engine.js
2. start reverse ajax polling
3. invoke a remote method which affects the script session

Here's what happens:
A script session is created for 1. but the scriptSessionId is not returned before 2. fires
scriptSessionId is null for 2. so another script session is created
3. uses the script session id from 1. since 2. has not returned yet
when 2. returns, the script session id changes
all subsequent dwr calls use the scriptSessionId returned from 2.
there are no pointers to script session 1 and it is effectively lost... therefore any initialization done in 3. is lost.

The current workaround is this:
function initReverseAjax() {
   if (dwr.engine._scriptSessionId == null) {
      setTimeout("initReverseAjax()", 2000);
   } else {
      dwr.engine.setActiveReverseAjax(true);
   }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值