[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2013-05-30
4
Medium Priority
?
411 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 750 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 84

Accepted Solution

by:
Dave Baldwin earned 750 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

Industry Leaders: 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

This article discusses how to implement server side field validation and display customized error messages to the client.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

656 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