I have a JSP page where I have created a form and a button. Once user clicks on submit button, form action will call servlet doPost method and does the business logic. Now I need to disable the submit button to prevent user to click on that button twice till my business execution completes. My JSP pages is as shown below
<body>
<form method="post" action="SubmitJob" id="myForm">
<table>
<td><p>Please use the below button to run the job immediately</p> <br>
<div id="runNow">
<input type="submit" name="runNow" value="runNow" id="submitBtn">
<% out.println(request.getAttribute("status")); %>
</div>
</td>
</tr>
</table>
</form>
</body>
To disable a submit button, I have used jquery and tried as follows
<script>
$(document).ready(function(){
$('#submitBtn').click(function(){
// $('form#myForm').submit();
alert('after form submit');
$('#submitBtn').prop("disabled",true);
alert('after button disabled');
});
});
</script>
problem I am facing is, form action will not be invoked if button is disabled. Can some one suggest me, 1)how to invoke form action first then disable the button. 2) how to enable the submit button again once business logic in my servlet completes.3) How to call servlet doPost method from my java method