Forum Moderators: open

Message Too Old, No Replies

Howto (on)unload with an running Ajax Request

page doesn't refresh or trigger the unload event.

         

BlackDex

12:35 pm on May 4, 2006 (gmt 0)

10+ Year Member



Hello there,

Is there a way to have an (on)unload while there is an running Ajax Request?

Currently when the request is still buzy, you can't reload the page.

I Want to detect when a user does an unload/refresh or whatever. And then execute an function wich can close stuff etc...

Thx in advanced..

siMKin

9:55 am on May 5, 2006 (gmt 0)

10+ Year Member



there's two ways to handle an ajax request, Synchronous & Asyncronous. One freezes everything until the request is done, the other allows you to keep using the page.
The difference is explained a bit more (:)) detailed here:
[webfx.eae.net...]
with a demo here:
[webfx.eae.net...]

So, that's probably the only thing you have to change (that boolean value)

BlackDex

5:56 am on May 8, 2006 (gmt 0)

10+ Year Member



Well.. i know the diff between those 2.

But with both, if you want to reload the page, this doesn't happen, not on any browser.

But i think what im looking for is imposilbe.

I Just want to have an request to be stopped when someone presses the refresh button or back.
Becouse now, when an async request is bussy, the browsers don't refresh or go back.

Thx anyway :).

siMKin

8:06 am on May 8, 2006 (gmt 0)

10+ Year Member



Either you're not implementing it right, or something else is wrong, but what i suggested earlier should solve your problem.

I put an example online for you so you can see it really does work:

[devshed.excudo.net...]

clicking on the Async or Sync link will active the same serverside script that will take approximately 5 seconds before it gives output.
As you can see, with the Sync button, the browser freezes and refreshing is not possible, whereas with the Async button refreshing ís possible. This worked for me in Firefox, Opera and IE

BlackDex

7:17 am on May 11, 2006 (gmt 0)

10+ Year Member



Hmmm...
Indeed...
But this is very strange.

I Have it on ASync.
I think i should do some debugging on my script.

Thx for the help :).