Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #25865

Re: Stopping Multi-submits ?

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: Stopping Multi-submits ?
Date 2014-09-24 02:50 +0200
Organization PointedEars Software (PES)
Message-ID <3821481.YS7cT2vfY4@PointedEars.de> (permalink)
References <c8dg58F7c6lU1@mid.individual.net> <lvsdp5$r0r$1@dont-email.me>

Show all headers | View raw


Cezary Tomczyk wrote:

> On 2014-09-23 16:58, Mel Smith wrote:
> [...]
>> Problem:
>>
>>      In IE11 (at least), after the new page arrives, if the user decides
>>      to use the 'back arrow' to re-load the previous page, then that
>>      submit button is *still* disabled, when I wish it to be enabled and
>>      ready for another submit
>>
>> Question:
>>
>>      How do I restrain multiple submits, *but* allow submits again after
>>      a new page has arrived, and then the user 'arrows' back to the
>>      previous page (or pages).
> [...]
> 
> Maybe do not disable the button, but instead of that when user clicks on
> the button set some state, e.g.:
> 
> var submitState = false;
> 
> to "true" and when the user clicks on button again just check that state
> and do the right action, e.g. if the state == true then show the message
> for the user that his "request is still in progress".

However, there is no guarantee that, using the Back feature, the pre-
existing environment will not be sufficiently restored.  A sufficiently 
reliable client-side possibility are cookies or Local/Session Storage 
instead; IOW, anything that is *not* tied to the document or view.  HTML5 
Push State and equivalents come to mind as well even though they are tied to 
the view.

Eventually, this can only be solved reliably server-side, by generating 
forms that are not cached (although this could be ignored by the UA as 
well), and submit tokens that are generated once, stored in a server-side 
session, and expire on successful form submission (anything else could 
result in accidental submission if the Forward feature is used 
subsequently).  This is also the recommended usability and security measure, 
given that client-side script code need not be executed.

It is possible to use XHR to improve the user experience, though: the 
submission of forms whose token has expired can be cancelled in advance.  
The negligible extra cost of this measure can result in a significant 
reduction of server load, depending on how much data is being sent when the 
submission is successful.
 
-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Stopping Multi-submits ? "Mel Smith" <syntel@cox.net> - 2014-09-23 08:58 -0600
  Re: Stopping Multi-submits ? Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2014-09-23 20:22 +0200
    Re: Stopping Multi-submits ? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-09-24 02:50 +0200
  Re: Stopping Multi-submits ? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-09-23 20:31 +0200
    Re: Stopping Multi-submits ? "Mel Smith" <syntel@cox.net> - 2014-09-23 16:27 -0600
      Re: Stopping Multi-submits ? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-09-24 00:54 +0200
        Re: Stopping Multi-submits ? "Mel Smith" <syntel@cox.net> - 2014-09-24 08:24 -0600

csiph-web