views:

252

answers:

1

Hey guys,

I'm using jQuery to dynamically load php pages into my page using the .load() function, so far this has been successful but if you click on various links to update the div with the .load() it starts to flicker between the new clicked page and the old one, this is pretty annoying and has anyone got a fix?

Current code:

$(document).ready(function(){
    $('a').click(function() {
      $('#content').load($(this).attr("href"));
      return false;
    }); 
});
A: 

The flickering is possibly caused because the dimensions of the #content div vary between loads, try to slideTogle it before loading or use another transition between loads

example :

$(document).ready(function(){
    $('a').click(function() {      
    $('#content').slideUp('slow',function(){
       $('#content').load($(this).attr("href"),function(data){
          $('#content').slideDown('slow'); 
      });
  })
  return false;
}); 
});
markcial