I have an animation with loading animations displayed during page loading after the form is submitted, and everything works fine. However, if you submit the form, and then click on the back arrow in the browser, it will display the previous page, and the .gif download is still visible.
I set it so that the gif loading is hidden when the page loads. But if you just click the back button in a browser (like firefox), it won’t completely reload the page and the gif animation will still be visible.
Is there a way to hide the .gif download when I click the browser back button?
Here is my jquery code:
<!-- inline scripts related to this page --> <script type="text/javascript"> // Show spinning animation on form submit. $("#filter-results-form").submit(function (e) { // Check for form errors before displaying loading gif. if ($('.field-validation-error').length > 1) { $("#loading-image").hide(); } else { $("#loading-image").show(0); // show animation } return true; // allow regular form submission }); </script>
Here is my relevant html:
<div> <button type="submit"><i class="fa fa-search"></i> Search</button> <span class="loading collapse" id="loading-image"><img src="@Url.Content("~/content/img/layout/ajax-loader.gif")"></span> </div>
And I tried this as a solution, but it does not work:
jQuery(function ($) { $("#loading-image").hide();
source share