It took me some time to find out when and why this happens.
When the window of Internet Explorer is closed with an AJAX call still
pending, something funny happens. Do it twice, and you will have to
restart the browser.
Here a little sample: http://truefriendz.de/iedos
The script on this site will open 5 test-windows one at a time.
The test-windows will issue an AJAX-Call. This call would only be
answered after 10 seconds, but the windows will be closed before
the answer arrives. (This is not a question of the window.close().
The same would happen if the close is issued by a user closing the
window)
Using IE6/w2k and IE7/vista (and assumedly other versions of IE)
the 3rd and following windows will appear without content. FireFox
performs perfectly well.
I found a workarround, which I regard as clumsy.
<body .... onAbort="cleanup();" onUnload="cleanup();">
function cleanup() { xmlHttp.abort();}
Demonstration here: http://truefriendz.de/iedos2
My findings so far: When a window with a pending AJAX-request
ActiveXObject("Microsoft.XMLHTTP") is closed, a TCP-socket remains
eternally in state close_wait. Check with netstat.
(It seems perfectly normal that sockets enter the state close_wait
(although if I understand the documents correctly this state should
only be entered by SERVERS),
and it seems that sockets can (normally) be reused succesfully from
this state. In "normal operation" such socktes do disappear after a
certain time)
My thoughts: Due to the fact that this Socket is still existing, IE
does
reuse it, but it does not work properly. These Sockets seem
to be damaged somehow.
Funny enough, I did not find any mention of this problem on the web.
Anyone, who can suggest a better, more elegant way to handle this?
Sorry for any mistakes, I did my very best, but I'm not a native
speaker.