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 undefined
Last Comment

8/22/2022 - Mon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

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.

All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck

Well, half way there.  I think it's got something to do with the asp.net side not closing connections.  Since that falls into asp.net 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 asp.net 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.