I try to show loader with percentage counter on page submit until it's redirect to home Page. but loader is not showing when I try to click on submit button. So How can I solve it?
JS code:
<pre>$(document).ready(function () {
$("#msform").on("submit", function () {
alert("in submit function");
$('#container1').show();
let circularProgress = document.querySelector(".circular-progress"),
progressValue = document.querySelector(".progress-value");
let progressStartValue = 0,
progressEndValue = 100,
speed = 100;
let progress = setInterval(() => {
progressStartValue++;
progressValue.textContent = `${progressStartValue}%`
circularProgress.style.background = `conic-gradient(#7d2ae8 ${progressStartValue * 3.6}deg, #ededed 0deg)`
if(progressStartValue == progressEndValue){
clearInterval(progress);
}
}, speed);
});
});
</script>
HTML CODE:(For circle loader)
<pre><div class="container1" id="container1" style="display:none;">
<div class="circular-progress">
0%
</div>
HTML & CSS
</div>
HTML Code : (for when I want to show loader on button click until page get back to the Homepage)
<pre> <form id="msform" class="needs-validation" novalidate method="POST" enctype="multipart/form-data">
<input type="submit" class="next action-button btn btn-primary" name="mainsubmit" value="Submit" id="nxtbtnwht1" />
</form>
What I have tried:
I have tried this
<pre><pre>$(document).ready(function () {
$("#msform").on("submit", function () {
alert("in submit function");
$('#container1').show();
let circularProgress = document.querySelector(".circular-progress"),
progressValue = document.querySelector(".progress-value");
let progressStartValue = 0,
progressEndValue = 100,
speed = 100;
let progress = setInterval(() => {
progressStartValue++;
progressValue.textContent = `${progressStartValue}%`
circularProgress.style.background = `conic-gradient(#7d2ae8 ${progressStartValue * 3.6}deg, #ededed 0deg)`
if(progressStartValue == progressEndValue){
clearInterval(progress);
}
}, speed);
});
});
</script>