The scenario is this:
if the XMLHttpRequest is in the state to enter the jahDone Function and you hit stop upload and the pop-up closes, the req variable can go away and that is bad.
I have updated xstatus.js to not close the pop-up window (either with the the stop transfer button or the close button of the pop-window) until any pending XML requests have completed.
Tested in Firefox and IE7.
I also noticed that the var req, wasn't defined anywhere.
Add this code to the top somewhere in the xstatus.js code
Code: Select all
// if we are going to close the pop-up
var windowClosing = false;
// not sure why this wasn't previously defined.
var req = null;
var wpTID;
// I want the close function of the pop-up to stop the upload transfer
window.onunload = ClosePopUp;
function ClosePopUp()
{
StopUpload(false);
}
function WaitPopupClose()
{
if (!req || !callInProgress(req))
{
popupClose();
clearInterval(wpTID);
}
}
Code: Select all
function StopUpload(no_close)
{
var op;
var agt=navigator.userAgent.toLowerCase();
var is_opera = (agt.indexOf("opera") != -1);
if(window.parent.frames['xupload']){op=window.parent;} else {op=window.opener;}
if (navigator.appVersion.indexOf("Safari")>0)
{
op.location.reload( true );
}
else if (!document.all || is_opera)
{
window.stop();
op.frames['xupload'].stop();
}
else
{
window.document.execCommand('Stop');
op.frames['xupload'].document.execCommand('Stop');
}
if(no_close)return;
// wait for any pending XML transactions to complete
if (!windowClosing)
{
windowClosing = true;
if (req && callInProgress(req))
{
wpTID = setInterval('WaitPopupClose()', 100);
}
else
{
popupClose();
}
}
}
Code: Select all
function jahDone(url)
{
if (req.readyState == 4)
{
// if the window is about to close, don't start another request
if (!windowClosing)
{
if (req.status == 200)
{
results = req.responseText;
window.clearTimeout(timeoutId);
try {eval(results);} catch(err) {timeoutId = window.setTimeout(function(){ jah(url); }, 1000 );}
}
else if(req.status == 500)
{
timeoutId = window.setTimeout(function(){ jah(url); }, 1000 );
}
}
}
}