I have a function in Javascript (in the browser, not node.js) that it takes a lot of time to commit. I want that while the function is being processed, the browser will present a loader, so the user can understand that he/she has to wait.
create a loader first :
<div class="loader" id="loader">
</div>
Then add the loader class in your CSS(css file of your loader class) :
.loader {
border: 16px solid #f3f3f3; /* Light grey */
border-top: 16px solid #3498db; /* Blue */
border-radius: 50%;
width: 120px;
height: 120px;
animation: spin 2s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.hide-loader{
display:none;
}
Add this js code to your JS file after your function executes completely,just hide the loader.
$('#loader').addClass("hide-loader");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With