Sunday, May 18, 2008

Tip: How to solve "__pendingCallbacks[...].async is null or not an object"?

Recently i came across this error "__pendingCallbacks[...]।async is null or not an object " when creating a callback function for a particular web page. After searching the web for a while, I solved the problem by re-creating the "WebForm_CallbackComplete" function in my callback page. The culprit to the problem is the variable "i" in the loop. Just change the "i" to "var i".


function WebForm_CallbackComplete() {
for (var i = 0; i < __pendingCallbacks.length; i++) {
callbackObject = __pendingCallbacks[i];
if (callbackObject && callbackObject.xmlRequest && (callbackObject.xmlRequest.readyState == 4)) {
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);
}
}
}
}

No comments: