I have built a form. When that form is submitted, the fields filled by users are send by the POST method to another page.
I use a spinner to display "Loading..." when the submit button is clicked. But the spinner never stops.
I'd like the spinner to be stopped when the form is submitted (I mean without giving a defined Timeout). How could I do ?
Here is the form part :
<form action = "getValues.php" method="post">
<div id = "field1" class="form-row"> <div class="form-group col-md-4">
<label for="exampleInputPassword1">Field 1</label>
<input type="text" class="form-control" id="field1-send" name="field1-send">
</div>
<button name="submit" type="submit" id="runSpinner" class="btn btn-primary"><i class="fas fa-check"></i> OK</button>
</form>
Here is the JS part :
$(document).ready(function() {
$("#runSpinner").click(function() {
// disable button
$(this).prop("disabled", true);
// add spinner to button
$(this).html(
'<span class="spinner-border text-warning" role="status" aria-hidden="true"></span> Traitement...'
);
});
});