I load external content to replace a DIV.
Problem is, when the ajax-loader.gif replaces the initial content the page shrinks in height and the scrollbar is likely to disappear. As soon as the external content is loaded the scrollbar reappears. That jerking takes away the smoothness.
Is there a smoother way? Maybe preserve the height of the div until the external content is loaded? I cannot use fixed heights. Here’s my function:
function(){
$('.filter a').click(function(){
$('#mydiv').html('<p><img src="ajax-loader.gif" /></p>');
$('#mydiv').load('/site/?key=Value');
return false;
});
(Project is a faceted search in WordPress).
Thank you!
You can load the content using $.ajax() and set the html of the div to the content it returns…
Edit: I assume your shifting is due to the loading image being smaller from your other comment… this should fix that:
have you tried setting the min-height?
something like this might work: