Solved

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

Posted on 2013-05-30
4
406 Views
Last Modified: 2013-06-06
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
Comment
Question by:nkialex
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 250 total points
ID: 39209460
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
 

Author Comment

by:nkialex
ID: 39223349
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
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 250 total points
ID: 39223364
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
 
LVL 82

Expert Comment

by:leakim971
ID: 39226981
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Jquery form 9 43
Rotate images for Web Page 11 28
How do I Enable submit button only if listbox has items 4 35
Javascript: Range object 16 16
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question