i'm facing sort of dummy problem.
on site there order form (simple html form) , noticed double commands time time.
i realized if clicked repeatedly few times submit button (before action page loaded) got many commands have clicked.
so wonder if there simple solution make form submission asyncronous?
thanks
p.s. added jquery ui dialog on submit "wait please..." still double commands.
update
as geoffatkins proposed will:
- disable submit after dialog shown
- make use of unique form's token (as added symfony) do not use symfony token unique form token same current session. use random or that.
i consider doing (jquery since said used that)
$(function() { $("#formid").on("submit",function() { $("#submitbut").hide(); $("#pleasewait").show(); }); });
if submit form , reload page.
if ajax order, do
$(function() { $("#formid").on("submit",function(e) { e.preventdefault(); var $theform = $(this); $("#submitbut").hide(); $("#pleasewait").show(); $.post($(this).attr("action"),$(this).serialize(),function() { $theform.reset(); $("#submitbut").show(); // assuming want user order more stuff $("#pleasewait").hide(); }); }); });
note disabling submit button on click of submit button may stop submission (at least in chrome): https://jsfiddle.net/mplungjan/xc6uc46m/
Comments
Post a Comment