• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

what are the possible reasons for request getting submitted twice?

 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the following validation on the form


How is the above different from the below:

 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Anything worth doing well is worth doing poorly first. Just look at this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic