View Full Version : [INFOREQ][3.1] Problems within window beforeunload event within Chrome
dtex-lab
3 Feb 2010, 11:23 PM
Hi,
The code below works with Firefox, Explorer, Safari but not with Chrome.
I have deeply debug the problem and I have see that:
- The 'request' method calls for 'urlAppend' function
- stepping into, the code seems to fails here:
return url + (url.indexOf('?') === -1 ? '?' : '&') + s;
Here the ExtJS code
Ext.onReady(function () {
window.onbeforeunload = function (aEvent) {
var vParam = {
rMessage: 'TestMessage'
};
var vUrl = 'TestClose.jsp';
Ext.Ajax.request({
url: vUrl,
success: function () {},
failure: function () {},
params: vParam,
async: false,
disableCaching: true
});
};
});
Note that the problem happens both using 'async : false' or not.
Here the JSP
<%@ page language="java" contentType="application/json; charset=UTF-8" %><%
String vMessage = request.getParameter("rMessage");
System.out.println("===> " + vMessage);
%>
To reproduce the problem
- Run the application
- Click on browser's refresh button
Using Explorer, Firefox, Safari you'll see a print out server side.
Using Chrome not, because of the error I had described before.
Thanks for your attention.
evant
3 Feb 2010, 11:56 PM
vParam is always going to be undefined, because you've defined it inside the method.
Why do you say this is a bug in Ext?
dtex-lab
4 Feb 2010, 12:01 AM
Hi Evant,
I say that is a bug in Ext because, as I had already said, the code I post WORKS within Explorer, Firefox and Safari but NOT only in Chrome.
Why that?
evant
4 Feb 2010, 12:06 AM
I misread.
evant
4 Feb 2010, 12:28 AM
It works for me in Chrome 4:
Ext.onReady(function(){
window.onbeforeunload = function(aEvent){
var vParam = {
rMessage: 'TestMessage'
};
var vUrl = 'data.asp';
Ext.Ajax.request({
url: vUrl,
success: function(){
},
failure: function(){
},
params: vParam,
async: false,
disableCaching: true
});
};
});
data.asp just dumps some text to a text file.
dtex-lab
4 Feb 2010, 4:34 AM
Hi Evant, I have done a lot of tests.
Now I have the exact scenario
This code does not works in Chrome only (Firefox, Explorer & Safari is OK)
Ext.onReady(function(){
window.onbeforeunload = function(aEvent){
var vMessage = 'test';
Ext.Ajax.request({
url: 'TestClose1.jsp?rMessage=' + vMessage,
success: function(){
},
failure: function(){
},
async: false,
disableCaching: true
});
};
});
This code work also in Chrome:
Ext.onReady(function(){
window.onbeforeunload = function(aEvent){
Ext.Ajax.request({
url: 'TestClose1.jsp?rMessage=MyTest',
success: function(){
},
failure: function(){
},
async: false,
disableCaching: true
});
};
});
To reproduce the problem
- Open your browser
- Open a new tab
- Open the application in that new tab
- Close that new tab
I am not able to reproduce the problem using 'asp' but I'm rather sure that the problem was the same.
Thanks.
Still can't get it to happen:
Ext.onReady(function(){
window.onbeforeunload = function(aEvent){
var vMessage = 'foo';
Ext.Ajax.request({
url: 'data.asp?rMessage=' + vMessage,
//url: 'data.asp?rMessage=bar',
success: function(){
},
failure: function(){
},
async: false,
disableCaching: true
});
};
});
Depending on which line, it always prints 'foo' or 'bar'.
Animal
4 Feb 2010, 5:26 AM
async: true/false is not valid.
It's supported by some extensions. COuld be a problem in the extension.
dtex-lab
4 Feb 2010, 6:13 AM
Hi
I had removed both ext-basex-debug.js from my include list and async : false from my ajax request but the problem still remains.
Works only with Chrome if I build the url without any variable (eg: url: 'data.asp?rMessage=bar')
Probably the only way for me is to perform a window.open(....) instead of making the ajax request.
I do not really figure why u can't reproduce the problem (I have no doubt that for u works),
but for me now the big problem is to understand why here not.
Another little information I had not provide u is that I'm using Ext 3.1 version, but, at this point, I imagine that has not any relation to the problem.
Thanks a lot for your help.
dtex-lab
4 Feb 2010, 7:08 AM
Hi Evant, excuse me again....
could u try wirhin this code, please?
Ext.onReady(function () {
window.onbeforeunload = function (aEvent) {
testClosing('test');
};
});
function testClosing(aMessage) {
var vMessage = aMessage;
Ext.Ajax.request({
url: 'TestClose.jsp?rMessage=' + vMessage,
success: function () {},
failure: function () {},
async: false,
disableCaching: true
});
}
It runs fine. You're just doing variations of the same code, but they will execute in the same way. I don't think this is a bug.
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.