$(document).ready(function() { // On the click of the submit button, start the function $("#loadBtn").click(function() { // Append the loading image to the div that the content is being loaded within $("#content").append('<div class="loading" style="display:block;"></div>'); // Load the file within the content div $(this).load("data.html", function(){ // Hide the loading image once the content has been loaded $(".loading", this).hide(); }); }); });
<input type="submit" id="loadBtn" value="Click Me!" /> <div id="content"></div>