ajax issue with explorer

D

Darko

Hi,

I'm making an application in which I use resident ajax request. That
means, I have a server-side application that collects ajax requests
and responds only when information available. I did so because I
didn't want to bomb the server with ajax requests every 5 seconds
(although even that is too much because it is critical to display the
right information as soon as it comes, to the user). So I create an
ajax request object, send a request, and then the onreadystatechange
event won't happen until the server responds. The server, however,
just collects sockets and when it is informed about a change (by
another server process), it sends it to all interested clients. It
works.

However, in Explorer I have an issue. It works as well as with
Firefox, sends the request, waits for it, and everything was fine
until I discovered that when I try to go to another page inside the
site, it just won't go! Refreshing, navigating to another page on the
site - nothing. Going from the page to, say, Google, works, but
requesting another information from my server just won't work. It
seems that the problem are these open connections. In firefox, they
just get killed, and everything is fine, but explorer won't do that.
Even when I close the page, and try to reopen it - that won't work
neither. I could only reopen the page by closing all Explorer tabs and
windows, then reopening it.

What could I do to solve the problem? I tried to register the onUnload
event, in which I kill all the open connections (not many of them
there are, usually up to 2-3, in real use it will be probably just
one), but that won't work neither - the onUnload is never called,
because it seems to wait for the connections to close for that too).

Anybody having had experience with resident ajax connections, anybody
having had similar problems? Thank you
 
D

Darko

Hi,

I'm making an application in which I use resident ajax request. That
means, I have a server-side application that collects ajax requests
and responds only when information available. I did so because I
didn't want to bomb the server with ajax requests every 5 seconds
(although even that is too much because it is critical to display the
right information as soon as it comes, to the user). So I create an
ajax request object, send a request, and then the onreadystatechange
event won't happen until the server responds. The server, however,
just collects sockets and when it is informed about a change (by
another server process), it sends it to all interested clients. It
works.

However, in Explorer I have an issue. It works as well as with
Firefox, sends the request, waits for it, and everything was fine
until I discovered that when I try to go to another page inside the
site, it just won't go! Refreshing, navigating to another page on the
site - nothing. Going from the page to, say, Google, works, but
requesting another information from my server just won't work. It
seems that the problem are these open connections. In firefox, they
just get killed, and everything is fine, but explorer won't do that.
Even when I close the page, and try to reopen it - that won't work
neither. I could only reopen the page by closing all Explorer tabs and
windows, then reopening it.

What could I do to solve the problem? I tried to register the onUnload
event, in which I kill all the open connections (not many of them
there are, usually up to 2-3, in real use it will be probably just
one), but that won't work neither - the onUnload is never called,
because it seems to wait for the connections to close for that too).

Anybody having had experience with resident ajax connections, anybody
having had similar problems? Thank you

Well, I sort of solved it. onUnload still COULD help me, but only for
the case when the user manually enters a new address or does a refresh
by F5 or similar. So, in the onUnload handler I call a function that
aborts all of the open connections. If I didn't do that, then it
wouldn't leave the neither. Then, for the links that exist on the
page, I made an onLoad handler, that prepends aborting the open
connections on their onclick event. Something like this:
var all = document.getElementsByTagName( "a" );
for ( i = 0; i < all.length; i++ )
if ( all.onclick ) {
var oldf = all.onclick;
all.onclick = function()
{
ObjectPrinter.killLiveDaemons();
oldf();
}
} else {
all.onclick = function()
{
ObjectPrinter.killLiveDaemons();
}
}
Of course, I included all submit-buttons in this, too. And it
works! :) Well, not a great solution, but it seems that adapting
scripts to work in IE isn't really an easy task.

Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top