I am using gif image for loading and it is the default display none and when the form is getting submitted it will display block and when ajax request get complete it will again display none as below
function showLoader() {
$("#loading-image").css("display", "block");
}
function hideLoader() {
$("#loading-image").css("display", "none");
}
$("#review_submit").click(function(e) {
e.preventDefault();
showLoader();
var fd = $("form").serialize();
$.ajax({
type: 'POST',
async : false,
url: '',
data: fd,
contentType: false,
processData: false,
success: function(response){
console.log(response);
hideLoader();
}
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form action="" id="review_form" method="post" class="wp-form" novalidate="novalidate">
<input type="text" name="product" />
<input class="add-my-review large_button" type="submit" id="review_submit" value="Add My Review" name="add_review">
</form>
<span class="ajax-loader" id="loading-image" style="display: none;">
<img alt="Loading..." src="/assets/images/loader.gif" />
</span>
but this code is not working in live
can anybody help me in this