This method worked for me:
HTML
<div id="load"><img src="loading_animation.gif" /></div> <div id="content">Display content once loaded</div>
Javascript
<script type="text/javascript"> $(document).ready(function() { $('#load').show(); // Show loading animation $('#content').hide(); // Hide content until loaded $(window).load(function() { $.ajax({ post: "GET", url: "your_file.php" // File that you're loading }).done(function() { alert("Finished!"); // Alert message on success for debugging $('#load').hide(); // Hide loading animation $('#content').show(); // Show content }).fail(function() { alert("Error!"); // Alert message if error for debugging }); }); }); </script>
source share