Recursive Form Submits?
I’ve been pounding my head trying to figure out a problem with one of our systems at work today. The problem was that we were running out of threads on our WebLogic 8.1 app server pretty fast. Last night I made a change to a login form that inconspicuously caused the problem. Here’s my form (I’ve stripped out all of the unnecessary crap):
... ...
I know this isn’t a great way to submit a form, but I have reasons for doing this. Take note of the onsubmit event in the form. This calls out a JavaScript function called genericFunction() that will also do a form submit. It’s a bit tricky. My initial thought was that the onsubmit event takes precedence over the standard form submit, but that’s where I’m wrong. It appears that the form actually fires off two submits in this case, causing multiple calls to your endpoint.
Is this obvious to most people?
July 28th, 2004 at 8:34 AM PDT
yep, you will get 2 submits.
Change the onsubmit=”genericFunction()” to onsubmit=”return genericFunction()” and then make genericFunction() return false.
Incidentally, the same logic is required for JS form validation functions.