This error occurs before the completed handler is even considered, so it doesn't make a difference whether you have a handler or not unfortunately.
this._onReadyStateChange = function () {
if (_this._xmlHttpRequest.readyState === 4 ) {
_this._clearTimer();
_this._responseAvailable = true;
_this._webRequest.completed(Sys.EventArgs.Empty); <-- this is where the error occurs in the MicrosoftAjax lirbrary
if (_this._xmlHttpRequest != null) {
_this._xmlHttpRequest.onreadystatechange = Function.emptyMethod;
_this._xmlHttpRequest = null;
}
}
} It is the completed method of WebRequest that looks for your completed handler to call. But it is here that Sys is undefined so we never make it to that method.
What appears to be happening is that during the transition to the next page, the DOM from the current page is being destroyed to make way for the next page when the web request returns and runs the onreadystatechange event handler, only to find that the microsoftajax library has been unloaded.
That's the only reason I can think that the Sys namespace would suddenly be unavailable.
Thanks,
Mike