473,387 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Canīt ensure submit is really executed

Hi all,
I want to submit a form when the user closes the browser, to keep a
count of the number of users accesing my application at each moment. To
do this, I use the onbeforeunload() event, that calls a function when I
call form.submit() method. The problem is that I have to put an
'alert()' after this line, if I remove the 'alert()' line, things
donīt work. The submit() method seems to return before the form is
really submitted, and the browser get closed, so the form is never
really submitted. I donīt want to have this annoying 'alert()'. Does
anybody know another way to ensure submit really executes before
browser get closed?
Thanks a lot.

Jul 23 '05 #1
3 1455

Why not submitting on load ?

Jul 23 '05 #2
besbello wrote:
Hi all,
I want to submit a form when the user closes the browser, to keep a
count of the number of users accesing my application at each moment. To
do this, I use the onbeforeunload() event, that calls a function when I
call form.submit() method. The problem is that I have to put an
'alert()' after this line, if I remove the 'alert()' line, things
donīt work. The submit() method seems to return before the form is
really submitted, and the browser get closed, so the form is never
really submitted. I donīt want to have this annoying 'alert()'. Does
anybody know another way to ensure submit really executes before
browser get closed?
Thanks a lot.


Just a suggestion: have you tried POSTing synchronously using an
XMLHTTPRequest? It seems like the most reliable JS-based option,
disregarding backward (and some sideways) compatibility.

And a note... disregarding backward or sideways compatbility is not
something I recommend. Regardless of the direction you choose to go,
have a backup such as the auto-expiring sessions database noted below.

There is no 100% reliable way to do what you're looking for, JS or no.
Some people open popups that do the job, but they are often blocked or
closed before they can get the job done, and they're irritating as
[snipped]. Some people use session databases where sessions are
considered expired after X minutes/seconds, but this is highly
inaccurate [best used as a fall-back] and might involve a lot of extra
server-side work. You might combine this with a periodic automatic
refresh of some kind (fifty ways to skin that cat) to keep sessions
alive.

Other software might be more reliable, but still run into
incompatibility and accuracy issues. A Flash or Java applet that keeps
the server aware of its state would work. Of course, the client machine
would have to have Flash or JRE installed and security settings
configured appropriately to allow them to communicate with your server
(i.e. via a TCP socket/connection).

For more information on XMLHTTPRequest, search the group archives at
Google and the group FAQ. Lots of great info.

For more info on Flash and Java... well, I wouldn't know. Go somewhere
else. ;)

Jul 23 '05 #3
Hi again,
Larsens : I haven`t explained it well. Yes, I increment de number of
users when I load the page, but I need to decrement it not only if the
user navigates to another page in my application (easy), but also when
he/she closes the browser or goes to a external page.
Christopher J. Hahn: Thanks a lot for your answer. Iīll take a look at
that.

Any other suggestion would be very appreciated

Christopher J. Hahn ha escrito:
besbello wrote:
Hi all,
I want to submit a form when the user closes the browser, to keep a
count of the number of users accesing my application at each moment. To
do this, I use the onbeforeunload() event, that calls a function when I
call form.submit() method. The problem is that I have to put an
'alert()' after this line, if I remove the 'alert()' line, things
donīt work. The submit() method seems to return before the form is
really submitted, and the browser get closed, so the form is never
really submitted. I donīt want to have this annoying 'alert()'. Does
anybody know another way to ensure submit really executes before
browser get closed?
Thanks a lot.


Just a suggestion: have you tried POSTing synchronously using an
XMLHTTPRequest? It seems like the most reliable JS-based option,
disregarding backward (and some sideways) compatibility.

And a note... disregarding backward or sideways compatbility is not
something I recommend. Regardless of the direction you choose to go,
have a backup such as the auto-expiring sessions database noted below.

There is no 100% reliable way to do what you're looking for, JS or no.
Some people open popups that do the job, but they are often blocked or
closed before they can get the job done, and they're irritating as
[snipped]. Some people use session databases where sessions are
considered expired after X minutes/seconds, but this is highly
inaccurate [best used as a fall-back] and might involve a lot of extra
server-side work. You might combine this with a periodic automatic
refresh of some kind (fifty ways to skin that cat) to keep sessions
alive.

Other software might be more reliable, but still run into
incompatibility and accuracy issues. A Flash or Java applet that keeps
the server aware of its state would work. Of course, the client machine
would have to have Flash or JRE installed and security settings
configured appropriately to allow them to communicate with your server
(i.e. via a TCP socket/connection).

For more information on XMLHTTPRequest, search the group archives at
Google and the group FAQ. Lots of great info.

For more info on Flash and Java... well, I wouldn't know. Go somewhere
else. ;)


Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: NotGiven | last post by:
I have a web page where certain pages have to be opened in a certain order and should only be available when the user openes them in HTTPS. They are all forms and the form action sends you to the...
10
by: john | last post by:
I want the page to completely ignore all mouse clicks. I can create the onmouseclick event and return false, but that only disables certain types of things. I can still, for example, click in a...
2
by: jw56578 | last post by:
if i have an Input type Image how am i suppose to programatically submit it through JS. code: <INPUT type="text" onkeyup="javascript:if(event.keyCode==13){btnClick.click();}"> <INPUT...
2
by: a10392 | last post by:
Hi, I'am triyng to create a form where i have 2 comboBox and 2 textbox, when the selection changes on the first combo , the content of second also changes. i have to use onchange=form.submit() ...
0
by: Fabio R. | last post by:
Every webform in my application inherit from a base custom class. In this class I override the OnLoad method and call the base.Onload in it. Sometimes, the OnLoad in the webform is not executed...
29
by: jens Jensen | last post by:
Hello, I got this "breath taking" task to write a an http server to which "xml data" will be posted to and will answer with xml data. The logic behind the xml processing is not a matter here. ...
1
by: dman | last post by:
<!DOCTYPE transactions > Suppose I have something like above. Is there a way to ensure that when the xml is validated, that every tag has some text in it through the DTD? Or does that need to be...
4
by: MLH | last post by:
How do I ensure my reports are being printed in max resolution of 1200dpi ? That is, can Access control the setting?
8
by: Markus | last post by:
Hello everyone. Recently I stumbled upon an interesting problem related to thread-parallel programming in C (and similarily C++). As an example assume a simple "buffer" array of size 8, e.g....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.