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);
}
}
dwr反推技术的一个问题
最新推荐文章于 2021-02-28 03:19:35 发布