'__pendingCallbacks[...].async' is null or not an object: callback async[i]...FIX :)
2008-05-27 15:04
591 查看
In my prior both articles about CALLBACK, which considered as Article of the Day @ www.asp.net recently might have problem:
Here i would like to talk about async indexer problem and of course solution as well :)
PROBLEM 1: '__pendingCallbacks[...].async' is null or not an object
EXPLANATION: if you debug then error message says, there is some problem with indexer [i] of async callback, hmmm you might not get that error message after using callback but developing other modules/part of the website you might get such error 1 day as i did :D, so if you are brainy enough, you must think something new i did which cause this ripple effect and go ahead to look for that what exactly i did and if you keep thinking with reading that error message carefully, you will get to know: somewhere you are using "i" variable and that variable is not being getting out of scope so mixing with "i" variable of callback async[i] and making problem.
Solutions:
1) solution is simple: follow standards and never make any variable name of single character rather use: anyhow either change your variable name from "i" to intCounter or anything u want
2) take care of your variable scope, so it wont mixup with variable "i"
3) use the following code/snippet: if you want to keep using your "i" variable in your code (may be you have used that at many places and don't wanna mess up with your existing code):
<script type="text/javascript">
function WebForm_CallbackComplete
_SyncFixed() {
// SyncFix: the original version uses "i" as global thereby resulting in javascript errors when "i" is used elsewhere in consuming pages
for (var i = 0; i < __pendingCallbacks.length; i++) {
callbackObject = __pendingCallbacks[ i ];
if (callbackObject && callbackObject.xmlRequest && (callbackObject.xmlRequest.readyState == 4)) {
// the callback should be executed after releasing all resources
// associated with this request.
// Originally if the callback gets executed here and the callback
// routine makes another ASP.NET ajax request then the pending slots and
// pending callbacks array gets messed up since the slot is not released
// before the next ASP.NET request comes.
// FIX: This statement has been moved below
// WebForm_ExecuteCallback(callbackObject);
if (!__pendingCallbacks[ i ].async) {
__synchronousCallBackIndex = -1;
}
__pendingCallbacks[i] = null;
var callbackFrameID = "__CALLBACKFRAME" + i;
var xmlRequestFrame = document.getElementById(callbackFrameID);
if (xmlRequestFrame) {
xmlRequestFrame.parentNode.removeChild(xmlRequestFrame);
}
// SyncFix: the following statement has been moved down from above;
WebForm_ExecuteCallback(callbackObject);
}
}
}
window.onload = function Onloaad(){
if (typeof (WebForm_CallbackComplete) == "function") {
// set the original version with fixed version
WebForm_CallbackComplete = WebForm_CallbackComplete_SyncFixed;
}
}
</script>
Here i would like to talk about async indexer problem and of course solution as well :)
PROBLEM 1: '__pendingCallbacks[...].async' is null or not an object
EXPLANATION: if you debug then error message says, there is some problem with indexer [i] of async callback, hmmm you might not get that error message after using callback but developing other modules/part of the website you might get such error 1 day as i did :D, so if you are brainy enough, you must think something new i did which cause this ripple effect and go ahead to look for that what exactly i did and if you keep thinking with reading that error message carefully, you will get to know: somewhere you are using "i" variable and that variable is not being getting out of scope so mixing with "i" variable of callback async[i] and making problem.
Solutions:
1) solution is simple: follow standards and never make any variable name of single character rather use: anyhow either change your variable name from "i" to intCounter or anything u want
2) take care of your variable scope, so it wont mixup with variable "i"
3) use the following code/snippet: if you want to keep using your "i" variable in your code (may be you have used that at many places and don't wanna mess up with your existing code):
<script type="text/javascript">
function WebForm_CallbackComplete
_SyncFixed() {
// SyncFix: the original version uses "i" as global thereby resulting in javascript errors when "i" is used elsewhere in consuming pages
for (var i = 0; i < __pendingCallbacks.length; i++) {
callbackObject = __pendingCallbacks[ i ];
if (callbackObject && callbackObject.xmlRequest && (callbackObject.xmlRequest.readyState == 4)) {
// the callback should be executed after releasing all resources
// associated with this request.
// Originally if the callback gets executed here and the callback
// routine makes another ASP.NET ajax request then the pending slots and
// pending callbacks array gets messed up since the slot is not released
// before the next ASP.NET request comes.
// FIX: This statement has been moved below
// WebForm_ExecuteCallback(callbackObject);
if (!__pendingCallbacks[ i ].async) {
__synchronousCallBackIndex = -1;
}
__pendingCallbacks[i] = null;
var callbackFrameID = "__CALLBACKFRAME" + i;
var xmlRequestFrame = document.getElementById(callbackFrameID);
if (xmlRequestFrame) {
xmlRequestFrame.parentNode.removeChild(xmlRequestFrame);
}
// SyncFix: the following statement has been moved down from above;
WebForm_ExecuteCallback(callbackObject);
}
}
}
window.onload = function Onloaad(){
if (typeof (WebForm_CallbackComplete) == "function") {
// set the original version with fixed version
WebForm_CallbackComplete = WebForm_CallbackComplete_SyncFixed;
}
}
</script>
相关文章推荐
- ICallbackEventHandler回调时的'__pendingCallbacks[...].async' is null or not an object错误处理
- '__pendingCallbacks[...].async' is null or not an object
- dojo.widget' is null or not an object
- “this._postbackSettings.async is null or not an object”问题的解决
- 'telnet' is not recognized as an internal or external command
- Bean property XX' is not writable or has an invalid setter method
- Spring配置文件加载时出现Bean property 'newscontentDAO' is not writable or has an invalid setter method错误的解决
- 用命令连接mysql , 出现'mysql' is not recognized as an internal or external command错误解决
- 使用flot绘图出现window.G_vmlCanvasManager is null or not an Object
- Bean property 'xxx' is not writable or has an invalid setter method
- 使用flot绘图出现window.G_vmlCanvasManager is null or not an Object
- Bean property 'service' is not writable or has an invalid setter method. Did you mean 'serivce'?
- 使用jqplot绘图出现window.G_vmlCanvasManager is null or not an Object
- ASP.NET 2.0 – ValidatorOnLoad “Microsoft Javascript runtime error: ‘null’ is null or not an object”
- Bean property XX' is not writable or has an invalid setter method
- 用命令连接mysql , 出现'mysql' is not recognized as an internal or external command错误解决
- Unable to get value of the property '2': object is null or undefined
- python TypeError: 'builtin_function_or_method' object is not iterable keys
- Bean property 'RegDao' is not writable or has an invalid setter method. Does the parameter type of t
- IF OBJECT_ID('UP_GET_XXX_SEQNO') IS NOT NULL