简体   繁体   English

在ajax请求后完全加载后淡入图像

[英]FadeIn an Image after being fully loaded after ajax request

My main objective is to a load a reasonably large image in to my #pictureframe div and fadeIn the loaded image. 我的主要目的是将相当大的图像加载到我的#pictureframe div中,并在加载的图像中淡入淡出。

The following code works well but the problem is that the image that is being loaded is not fading In as expected. 以下代码可以正常工作,但是问题是正在加载的图像没有像预期的那样褪色。

My html page is 我的html页面是

<div id="picture">

    <div id="pictureframe">
    </div>

</div>

Also my Java script function is as follows 另外我的Java脚本功能如下

$('#content').on('click',".lstimages .imgthumb",(function(){


    var photoid = $(this).attr('alt');

    $.ajax({
    dataType: "json",
    url: '/ajax/pictureview/load/' + photoid,
    success: loadImg
    ,
    error: function (xhr, ajaxOptions, thrownError) {
    alert(xhr.status);
    alert(thrownError);
    }
    });


    }));


    function loadImg(data)
    {

        $('#picture > #pictureframe').hide().html("<img alt='"+ data[0].pictureid +"' src='"+ data[0].filepath + "'>").fadeIn();


    }

if found the answer 如果找到答案

$('#picture > #pictureframe').hide().html("<img alt='"+ data[0].pictureid +"' src='"+ data[0].filepath + "'>");


$('#picture > #pictureframe img').bind("load", function() {
        $('#picture > #pictureframe').fadeIn();  
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM