• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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: 67746
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.
 
My previous laptop never exploded like that. Read this tiny ad while I sweep up the shards.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic