On Fri, Apr 17, 2009 at 3:25 AM, Govinda <govinda.webdnat...@gmail.com> wrote:
>
> Hi all,
>
> I am brand new here.  Except for quick installs of pre-written scripts
> over the years, I have very little experience of javascript (do we use
> the acronym "js" here?)  I have written in visual basic (I was last
> semi-fluent with the 1998 version), and in WebDNA for 10 years (server-
> side web scripting language, like PHP, only much less known).
>
> I am writing to ask your opinions about accomplishing a solution to
> our need.  I am not sure if we can do this with jQuery or js?
>
> Here is what I need your opinion about how to solve:
>  We have a series of forms for the user to submit.  We gather various
> data from the user at each form.  We save his input to disk at every
> form submission but also eventually want to do some final processing
> on his input (do some math, over and above just saving his input).  We
> only want to process his data once we have accumulated as much data
> from his as possible.. i.e. as much as he has patience to input for
> us.  *One special thing is that we can only do this final processing
> one time.*  Ideally we want to wait until he reaches formN to do this
> final processing of his data.  But if we knew he was only going to
> stick around to see form3 and then leave..  then we would simply do
> the final processing after he submitted form2.  The problem is that we
> never know when the user will get tired and leave.  We would do the
> final processing earlier before losing him, but we can only process
> once and we don't want to miss the chance to gather yet more data from
> him before we process.  If he leaves our site at form2 (or form3, or
> form4, for example) then we want to process whatever data we have
> gathered from him in total...  meaning *as if he had submitted the
> form* he is now looking at after having checked the checkbox which
> says "this is my last form!".  We want to process as though he
> submitted one last form after alerting us that it was going to be his
> last submission - even though he is actually now leaving our site by
> closing the browser window, or closing the browser tab, or entering a
> new URL to go to..  or using a browser bookmark ..
>   I assume there is a way to capture the event that fires when
> someone closes the browser window, closes the tab, (or also even if he
> just leaves our domain within the current window/tab?)..?
>   Can I capture all these possible events (and others that you can
> think of that I neglect to mention here) into one umbrella event that
> fires and effectively submits the current form one last time - thus
> signaling to our server to go ahead with the final processing?
>
> If  jQuery does not have this capability, then what about javascript?
> Please advise!
>
> Thanks for your time reading this.
> -Govinda
>

Try "unload" event on body tag.

you even try jquery way.
$(window).unload(function {
//whatever you want to do
});

refer: http://docs.jquery.com/Events/unload#fn

-raja koduru

Reply via email to