[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 413
  • Last Modified:

Lifetime of HTML page after document.forms(0).submit()

I cautioned a member of my staff who had something like  the following code:

function sub() {
	document.forms(0).submit();
	myfn();
}

Open in new window

"That line of code after after the 'submit' will never be executed," I said, because control is passed to the CGI page you're submitting to as soon as line 2 is executed," but sure enough, the thing works. In fact, some testing revealed that any code added to the end of the function "sub()" runs before the CGI page gets control (IE 9).

I can't find this documented anywhere, but is this expected behavior? I thought a Submit() was akin to an <a href> is that control is immediately passed to the "Action" Can someone please explain to me the lifecycle/flow of a form submission? When does the calling page with the form "die"?
0
nkialex
Asked:
nkialex
  • 2
2 Solutions
 
leakim971PluritechnicianCommented:
http://www.eventhelix.com/realtimemantra/networking/HTTP_Post.pdf
http://www.w3.org/TR/html401/interact/forms.html#h-17.13.3

so you're looking for delay of processing the form submission
this tcp/ip connexion is slow comparing executing a function (if the function don't have itself a slow process)

but you should use different logic and put myfn() before
0
 
nkialexAuthor Commented:
Actually, I'm not looking for a delay of form processing, but getting one regardless. The post seems to not be done until the function that contains the submit method completes! This I can't find documented anywhere. I know the mfn() should go before -- my question is, why does it work when it goes after?!
0
 
Dave BaldwinFixer of ProblemsCommented:
That could depend on what you are submitting and how long it takes.  Control doesn't actually 'pass' until you get the response back from the server.  If you are uploading files, that could take a while.  Or if the server response is slow.
0
 
leakim971PluritechnicianCommented:
Actually, I'm not looking for a delay of form processing

Open in new window

You need to look for it because this is the answer of your question :
why does it work when it goes after?!

Open in new window

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now