• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what are the possible reasons for request getting submitted twice?

 
Christian Nash
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

in my application, the request is getting submitted twice even though i'm submitting the form only once by clicking on the submit button? What might be the possible reasons for the request getting submitted twice?
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you know that its getting submitted twice ?
 
Christian Nash
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
through the log messages..i see that the requests are getting submitted twice, one after the other..and both are POST
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
never exclude the possibility that your logging may be wrong.

If you have validation on the form, the following will cause the form to the submitted twice:



The form gets submitted by both the initial submit AND the form.submit()
[ May 09, 2007: Message edited by: David O'Meara ]
 
Christian Nash
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following validation on the form


How is the above different from the below:

 
Bosun Bello
Ranch Hand
Posts: 1510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With return false, the form will not be submitted. Returning true will cause it to be submitted if the action is onSubmit.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bosun Bello:
With return false, the form will not be submitted. Returning true will cause it to be submitted if the action is onSubmit.


I do not think returning false from the javascript will help.It will still resubmit the form.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Christian Nash:



How is the above different from the below:



What is the use of the validation function that you are putting ? its just submitting the form.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe we're getting side tracked. We know what the problem is and why, shouldn't we concentrate on removing one?
 
Anupam Sinha
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is <html:image... sounds like JSF to me which I have a very limited idea of. The rason that comes to my mind is that the request is getting submitted twice because the <htm:image... is being rendered as a submit button for the form. something like <input type="image" .... See the generated code to see if that's the case. So in that case when you click on the image, the image would submit the request and inturn also call the submit method which would again submit the method. Try removing the submit from the submit() function and see if it helps.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64721
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is exactly as previously stated: the click of the image button (which has submit semantics) is initiating a form submission. Within the handler, the form is also be submitted under script control by calling submit. The results is a double submission.

Either the original submission must be derailed (by returning false from the handler), or the submit() method should not be called. I;d opt for the latter as the call is completely unecessary.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic