Link to home
Start Free TrialLog in
Avatar of UnexplainedWays

asked on

onunload + AJAX

I have a popup window with <body onunload="Something()">  The function Something() uses AJAX to call a page to remove something from the database.

I open up three of these windows.  When i close the first 2 the page is called (tested with breakpoints) but the last doesn't.  The function is being called because i put in an alert statment in the function.

The really weird part is if i only open 1 or 2 windows then it call's the page when it's shut, just seems to be the third.

Any ideas?
Avatar of system_down
Flag of Switzerland image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of UnexplainedWays


Normally i post code because i know you can't just pull an answer from u know where, however this code is a wrapper and to understand it will involve quite a few files and to trace alot of code and thats quite alot of work to do to try to track this error.

Basically it just make's an AJAX call, and then does nothing.  I tried opening more windows (7) and when closing the first 2 it worked, it seems to always be the third window for some odd reason.

I thought someone might of found a problem with multiple windows.

I'll write up a cut down version so you can see some code.
Well, the testing proved it can work with alot more than 3 windows, bugga.
Well, half way there.  I think it's got something to do with the side not closing connections.  Since that falls into not javascript i've asked a Q in the main area.

I was using Response.End(), which has always worked, but for some reason when using it when a window closes it causes an error, and i have to use Response.Close();

And i went though all that javascript for a error, ah well.

Thats why i thought the '3' was odd, i guess it couldn't handle 3 connections to a single used at the same time.