I'm having trouble getting a spinner to show up when a user clicks a form submit button. Below is the HTML code to add a <div>
for the spinner:
<div class="pageloader">
<img src="../images/loader-large.gif" alt="Please wait..." />
</div>
Here is the CSS for the pageloader
class:
.pageloader {
background: rgba( 255, 255, 255, 0.8 );
display: none;
height: 100%;
position: fixed;
width: 100%;
z-index: 9999;
}
.pageloader img {
left: 50%;
margin-left: -32px;
margin-top: -32px;
position: absolute;
top: 50%;
}
When the submit button in the form is clicked, I trigger this code in my script:
$(".pageloader").fadeIn();
After making an AJAX call, in the always
block, I use this code:
$(".pageloader").fadeOut();
However, when I test the form submission, the spinner doesn't show up despite firing the AJAX call, and I don't see any error messages in the console. Any ideas on what might be the issue here? Thanks!