I have the following HTML
<a href="/loadme.html" class="next">Load this content</a>
<a href"/loadmeto.html" class="next">Load some other content</a>
<div id="ajaxcontent"></div>
<div id="ajaxloader">*obligatory animated gif*</div>
And the following jquery which first loads some content on initial page load, and then subsequently overwrites it with other content when the .next buttons are clicked:
// Load the default initial content
$(document).ready(function() {
$('#ajaxcontent').load('/keyplate/1');
});
// Dynamically GET the content via Ajax
$(document).on("click", ".next", function(){
var link = $(this).attr('href');
$('#ajaxcontent').fadeOut('fast', function() {
$.get(
link +' #ajaxcontent',
function(data) {
$("#ajaxcontent").html(data).fadeIn('fast');
},
"html"
);
});
return false;
});
What I need some help on is how I can show/hide the loading div:
a) initially when the page is loading the default content; and b) subsequently when the .next href content is being loaded
Thanks in advance!