dwr官网上说:The global preHook is called before the batch and call preHooks. The global
postHook is called after the call and batch postHooks.可是我试出来怎么不一样呢?代码如下:
function batchHookTest(){
DWREngine.setPreHook(function(){
engineTestCallbackHandler("global_preHook");});
DWREngine.setPostHook(function(){
engineTestCallbackHandler("global_postHook");}); DWREngine.setAsync(false); DWREngine.beginBatch(); EngineTest.batchTest("load1", {
preHook:function(){engineTestCallbackHandler("single_preHook1");},
postHook:function(){engineTestCallbackHandler("single_postHook1");},
callback:engineTestCallbackHandler
}); EngineTest.batchTest("load2", {
preHook:function(){engineTestCallbackHandler("single_preHook2");},
postHook:function(){engineTestCallbackHandler("single_postHook2");},
callback:engineTestCallbackHandler
}); EngineTest.batchTest("load3", {
preHook:function(){engineTestCallbackHandler("single_preHook3");},
postHook:function(){engineTestCallbackHandler("single_postHook3");},
callback:engineTestCallbackHandler
}); engineTestCallbackHandler("before_endBatch"); DWREngine.endBatch({
preHook:function(){engineTestCallbackHandler("batch_preHook");},
postHook:function(){engineTestCallbackHandler("batch_postHook");},
}); DWREngine.setAsync(true);
}
function engineTestCallbackHandler(backData){
$("engineTestShowArea").innerHTML += "<br/>"+backData;
}
打印结果如下:
before_endBatch
batch_preHook
single_preHook3
single_preHook2
single_preHook1
global_preHook
global_postHook
single_postHook1
single_postHook2
single_postHook3
batchTest_load1
batchTest_load2
batchTest_load3
postHook is called after the call and batch postHooks.可是我试出来怎么不一样呢?代码如下:
function batchHookTest(){
DWREngine.setPreHook(function(){
engineTestCallbackHandler("global_preHook");});
DWREngine.setPostHook(function(){
engineTestCallbackHandler("global_postHook");}); DWREngine.setAsync(false); DWREngine.beginBatch(); EngineTest.batchTest("load1", {
preHook:function(){engineTestCallbackHandler("single_preHook1");},
postHook:function(){engineTestCallbackHandler("single_postHook1");},
callback:engineTestCallbackHandler
}); EngineTest.batchTest("load2", {
preHook:function(){engineTestCallbackHandler("single_preHook2");},
postHook:function(){engineTestCallbackHandler("single_postHook2");},
callback:engineTestCallbackHandler
}); EngineTest.batchTest("load3", {
preHook:function(){engineTestCallbackHandler("single_preHook3");},
postHook:function(){engineTestCallbackHandler("single_postHook3");},
callback:engineTestCallbackHandler
}); engineTestCallbackHandler("before_endBatch"); DWREngine.endBatch({
preHook:function(){engineTestCallbackHandler("batch_preHook");},
postHook:function(){engineTestCallbackHandler("batch_postHook");},
}); DWREngine.setAsync(true);
}
function engineTestCallbackHandler(backData){
$("engineTestShowArea").innerHTML += "<br/>"+backData;
}
打印结果如下:
before_endBatch
batch_preHook
single_preHook3
single_preHook2
single_preHook1
global_preHook
global_postHook
single_postHook1
single_postHook2
single_postHook3
batchTest_load1
batchTest_load2
batchTest_load3
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货