PDA

View Full Version : Ext.Ajax.request problem in IE8



Phantom
13 Jan 2011, 7:57 AM
Ext version tested:

Ext 3.3.1 - bug is present
Ext 3.2.1 - bug is not present


Adapter used:

ext


css used:

only default ext-all.css


Browser versions tested against:

IE8 - bug is present
IE8 Compatibility mode - bug is present
IE7 - bug is present
FF 3.6.13 (firebug 1.4.5 installed) - bug is not present
Chrome 8.0.552.224 - bug is not present


Operating System:

Win7 Pro


Description:
In one of my projects customers need to close the session (logout) when application's page is reloaded, location changed or browser window/tab is closed. So i put an eventHandler for the 'unload' event like


Ext.lib.Event.addListener(window, 'unload', function(){
Ext.Ajax.request({
url : 'do_logout.php'
});
alert("Session has been closed");
});

This code has worked nice with Ext 3.2.1, but after i have upgraded to Ext 3.3.1, it has stopped working in IE.

See this URL :
http://labs.ibissoft.se/ext331_bug/


Steps to reproduce the problem:

open the URL specified above
click on the "Reload" button or press F5 to reload the page


The result that was expected:

A message "Session has been closed" should arise


The result that occurs instead:

Nothing happens
After i have modified the ext-base-debug.js file and replaced 'catch(ex){}' with 'catch(ex){alert(ex);}' a message 'TypeError: Object doesn't support this property or method' gets alerted.


Debugging already done:

The error occurs in the line #1931 of ext-base-debug.js
It seems that checkTimeout.createCallback gets undefined in that particular case
I have found that there is a function fnCleanUp defined at the bottom of ext-base-debug.js :


if (Ext.isIE) {
function fnCleanUp() {
var p = Function.prototype;
delete p.createSequence;
delete p.defer;
delete p.createDelegate;
delete p.createCallback;
delete p.createInterceptor;

window.detachEvent("onunload", fnCleanUp);
}
window.attachEvent("onunload", fnCleanUp);
}

This function gets called before the other eventHandlers defined for the 'unload' event, so createCallback gets deleted before usage.
Same thing happens at the line #1933


Possible fix:

It was not possible to use Ext.override for the local function, so i had to patch ext-base{-debug}.js files directly.
I replaced lines ##1929-1933 with the following code:


if (cbTimeout) {
pub.conn[tId] = conn;
if ((Ext.isIE) && (typeof(checkTimeout.createCallback) == "undefined")) {
pub.timeout[tId] = setTimeout(function() { checkTimeout(o, callback);}, cbTimeout);
} else {
pub.timeout[tId] = setTimeout(checkTimeout.createCallback(o, callback), cbTimeout);
}
}
if ((Ext.isIE) && (typeof(checkResponse.createCallback) == "undefined")) {
poll[tId] = setInterval(function() {
checkResponse(o, callback, conn, tId, poll, cbTimeout);
},pub.pollInterval);
} else {
poll[tId] = setInterval(checkResponse.createCallback(o, callback, conn, tId, poll, cbTimeout), pub.pollInterval);
}

Condor
13 Jan 2011, 10:40 AM
Luckily this will automatically solve itself in Ext 4, because it no longer adds methods to the Function prototype.

ps. I would recommend using Ext.EventManager.on(...) instead of Ext.lib.Event.addListener(...).