开发者

jQuery load function with fading effects not working as expected

开发者 https://www.devze.com 2022-12-23 09:45 出处:网络
I have the following scenario jQuery(\'#content\').fadeOut(\'slow\',function(){ jQuery(\'#content\').load(\"detail.php?product=\"+imgID+\"&category=\"+cat);

I have the following scenario

jQuery('#content').fadeOut('slow',function(){
    jQuery('#content').load("detail.php?product="+imgID+"&category="+cat);
    jQuery('#content').fadeIn('fast');
});

My problem however is that all the effects happen and when the effects are done, then only the contents of the PHP file loads into content, is there a better way so that the content is not slow in loadi开发者_如何学JAVAng


Try using the callback function of the load function. Like so:

jQuery("#content").load("detail.php?product="+imgID+"&category="+cat, function()
{
    jQuery("#content").fadeIn("fast");
});

This way; your animation won't start until the content has been loaded.

0

精彩评论

暂无评论...
验证码 换一张
取 消