Form contains show PDF button which sends POST request.
This post request shows pdf file using Content-disposition: inline or Content-disposition: attachment http header.
In Chrome double click in this button causes exception in controller probably becauses request
is executed two times concurrently.
How to prevent this so that double click in submit button executes request only once ?
Environment: ASP .NET MVC2 or Mono, jquery, jquery ui.
<form id="_form" method='post' target='_blank' action=''>
.. form fields and other submit buttons
<a href='#' id='_savepdf'>Show PDF</a>
</form>
<script type="text/javascript">
$(function () {
$('#_savepdf').button();
$('#_savepdf').click(function () {
$('#_form')[0].action= '/GetPDF';
$('#_form')[0].submit();
});
});
</script>
Update
User may want to close pdf file and click or double click in this button again.
Only concurrent controller execution from same users should disabled. If controller has completed, button can clicked again.
You can disable the button after click so a user cannot click more than once.