473,729 Members | 2,150 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

AJAX "crashes" IE on close of Window.

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="cleanu p();" onUnload="clean up();">
function cleanup() { xmlHttp.abort() ;}

Demonstration here: http://truefriendz.de/iedos2

My findings so far: When a window with a pending AJAX-request
ActiveXObject(" Microsoft.XMLHT TP") 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.

May 7 '07 #1
5 13927
So********@goog lemail.com wrote:
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.
Really? In my Internet Explorer 6 it merely says it is opening and
closing windows, but it does not open or close anything.

I do however get:

Line: 39
Char: 2
Error: Object doesn't support this property or method
Code: 0
URL: http://truefriendz.de/iedos/

....5 times.

<snip>

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
May 8 '07 #2
On May 8, 2:51 am, -Lost <maventheextraw o...@techie.com wrote:
The script on this site will open 5 test-windows one at a time.
Really? In my Internet Explorer 6 it merely says it is opening and
closing windows, but it does not open or close anything.
Well, it should, and it *does* on my computer. :)

Thank for giving it a try. The site where this script is hosted is
not mine, so I can do nothing about it *at this site*. But I
made a modified copy here:

http://sommerb.so.funpic.de/ajax/iedos.html

Perhaps this one wil do the Trick. Sorry, this site is not cpmpletely
ad-free, but this was the only PHP-enabled web space I could find
in short time.

I would be very grateful if anybody would have a look at this. I'm
completely at loss, since I found out that even the version *with*
calls to abort() of the AJAX does indeed throw a exception in
FireFox.

TIA

May 8 '07 #3
Just to give more informations:

<head>
var xmlHttp;

function ajax_call(){

//create AJAX.object
xmlHttp = new ActiveXObject(v ersions[idx]);

// Define onreadystatecha nge and issue call to very slow site
xmlHttp.open('G ET', 'response-10s.php', true);
xmlHttp.onready statechange = function () {
if (xmlHttp.readyS tate == 4 && xmlHttp.status == 200) {
alert(xmlHttp.r esponseText);
}
};
xmlHttp.send(nu ll);
}

function cleanup() {
if (xmlHttp) {xmlHttp.abort( )}
}
</head>

<body onLoad="ajax_ca ll();" onAbort="cleanu p();" onUnload="clean up();"
>
....

Without cleanup() this will do damage to Internet-Explorer
(sockets permanently in state close_wait) if the window
is closed with the AJAX still waiting for the response.

Obviously the Ajax doesn't "like" to go into non-existence
without a pending call beeing aborted.

I have very foggy ideas about an Ajax-object that enlists
itself for cleanup...

Somehow to add this cleanup into a chain of operations that are
done automatically on close of the window. I examined some
AJAX-Libraries, but found nothing like that in any of them.

May 8 '07 #4
So********@goog lemail.com wrote:
I would be very grateful if anybody would have a look at this. I'm
completely at loss, since I found out that even the version *with*
calls to abort() of the AJAX does indeed throw a exception in
FireFox.
I do not have the time to peruse your code again, but I can tell you two
things.

1) Depending on your use of your XHR object, abort() is not necessary.
For example, calling the open() method twice on a single XHR object
will reset the object, its connection (what was previously opened/sent),
and will disconnect any event handlers.

2) Firefox does not like the abort() method. Most notably in cases of
use in the onreadystatecha nge event.

NOTE: About the above, it is essential to use abort() in Firefox when
canceling an XHR request, just not in the above mentioned event.

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
May 8 '07 #5
So********@goog lemail.com wrote:
>
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.
This sounds like a manifestation of a garbage-collection bug in IE.
When a document references javascript, and the javascript references
back to the document (which is pretty much all the time with AJAX)
then closing the document won't cause the javascript to be terminated.

Furthermore, IE has a very small limit on the number of connections
that it will allow to be simultaneously open to a given site. This
means that when your XmlHttp connections don't terminate, you quickly
run out of connections. This leaves you stuck until the XmlHttp
connections time out, which can take several minutes.

It's a pain in the ass. IE has had this bug for years. I don't know
if the newest version of IE still has the bug, but you have to plan
for the worst -- assume IE always has the bug.

See http://www.litotes.demon.co.uk/examp...finalizer.html
for more on the problem, and one possible solution.

Another technique which I've read about BUT NEVER TRIED is to use
different names for the server, so you increase the number of possible
connections. For example, supposedly "google.com " and "www.google.com "
will have separate connection pools even if they reference the same
site. The reason I never tried this technique is that it seems like
it'd take a lot of intricate site-specific engineering to make it
work reliably.
May 9 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2804
by: f.ruecker | last post by:
Hey Folks, I hope you'll be nice to me and let this post go through even know its mysql and not directly php. But of course my script is php. The problem is, that my Table (1,8 MIO entries/100 MB/MyISAM) is not working anymore. Everytime my script wants to write in something the number of entries decreases, and at the "Overhead" column the number is growing.
24
4488
by: sinister | last post by:
After doing a websearch, it appears that it's OK to omit the "http:" to form a relative URL. Are there any pitfalls to this? For example, if there is a page http://www.domain1.com/page1.html with a link to http://www.domain2.com/page2.html you can abbreviate the second link as //www.domain2.com/page2.html
6
2124
by: (Pete Cresswell) | last post by:
I'm makeing a little DB to help manage high school class reunions. One feature I'm trying to implement is "Friends". e.g. Fred Smith is a friend of Joe Jones and Bill Anderson. We record that so that when Fred moves and our mailing bounces, we can call Joe and/or Bill in hopes of getting Fred's new address. I started implementing this as just tblFriend linked to tblPerson on PersonID plus another link to tblPerson on FriendID.
5
4451
by: _BNC | last post by:
I've converted " byte" to "byte *" at times, using 'unsafe' and fixed { .... }, but the reverse does not seem to work. In this case, a C++ DLL returns a byte * and a length. What is the best way to convert these to straight C#-compatible straight " byte" arrays? PS: The C++ DLL is actually managed and I have access to the source. Perhaps there is a simpler syntax for doing the conversion there, and returning a C# compatible array...
7
2628
by: Simon Verona | last post by:
I have a problem in my application which I believe is due to open handles.. . The symptom that users report is that after they have been using the application for a while, it will randomly just crash with an exception report (I've not got the details of the error, but I'm working on that now!). I'm trying to reproduce the circumstances by simulating a typical batch of user tasks on my pc and monitoring whats happening. I'm guessing it's...
3
2925
by: Jerry | last post by:
I have created an application using wxPython and compiled it using py2exe. When I put setup(console=) in my setup.py file, the resulting application runs just fine. But when I change it to setup(windows=)
10
10046
by: morangolds | last post by:
Hi, I've been having a problem with C++ Windows Forms apps not "ending" when you close the form window. I've searched about this problem all over the place and most searches have lead me to believe that this has to do with unreleased form component events or event handlers. I'm comparatively new to .net and windows forms, in the sense that though I've been using them for over 2 years now, it's been rather sporadic. I work with...
1
1320
by: Toni | last post by:
Hello! I have a problem that I hope someone could help me with. Recently a web application was ordered from a software developer and installed on the server of my working place. This application uses a web service that runs on the same server. My job was to make changes to a couple of forms which were then put to the server to replace existing files. Now, when these forms are executed they seem to have trouble finding the web service and...
9
3361
by: andrew.smith.cpp | last post by:
hi, whts the difference between the std::endl or "\n" ? because both do the same work Thanks
0
9280
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9200
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8144
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6016
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2162
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.