I use the POST/REDIRECT/GET trick to prevent refresh-resend of forms. Now I would like to disable a form submit button (after click) that should not be clicked twice. Although I tried all javascript examples I found, they all conflict with POST/REDIRECT/GET. In most cases it doesn't even submit but just redirects to itself. Any solution ? Thanks for your help.
Something I've tried and conflicts is this example:
the script first runs headers.php with this in:
if (isset($_POST['start-diff-scan']))
{
$_SESSION['SCAN_START'] = true;
header('HTTP/1.1 303 See Other');
header('Location: '.APP_URL.'scan.php');
exit;
}
and then scan.php with this form:
<form name="start-diff-scan" id="start-diff-scan" method="post">
<button
name="start-scan"
id="start-scan"
value=""
class="start-scan btn btn-primary"
type="submit"
method="post">
Start New Scan
</button>
</form>
and works fine. but the js trick conflicts this. I added the js code at the very end of scan.php
<script>
$('#start-diff-scan').submit(function()
{
$('#start-scan').prop('disabled', true);
});
</script>
What happens is it only redirects to the same page (scan.php) without executing anything. Thanks for all yoru answers and help so far this is great. Any ideas appreciated thanks very much