加载图片不显示jquery

时间:2014-04-04 03:47:05

标签: jquery ajax

我有一个文件上传按钮,通过ajax上传文件,我每3秒发送一次ajax请求显示上传的图片,问题是,我想在用户点击上传按钮时显示加载图片隐藏它成功,但图像没有显示。如上所述,我有另一个ajax调用来获取上传的图片,我认为它隐藏了图片。所以我想要的只是,当用户点击按钮显示加载图像时,当第二个ajax调用将上传的图像显示回用户时,隐藏图像。有人可以给我提示吗?

$("#loading_image").html('<div class="loadm"><img src="../image/ajax-loader.gif"/>//I have tried putting the loading image on the also.

$(document).ready(function()
{
     profileRefresh();
    var uploaded_files_location = "../img/";
    new AjaxUpload($('#upload_button '), 
    {   
        hoverClass: 'btn - primary',
        action: 'picture.php ? target = profile ',
        name: 'file_to_upload ',
        onSubmit: function(file, file_extensions){
            $('#errormsg ').html('');

            if (!(file_extensions && /^(jpg|png|jpeg|gif|JPG)$/.test(file_extensions)))
            {
                $('#error ').html(' < div class = "error" align = "left" > Sorry, you can only upload the following file formats : JPG, JPEG, PNG and GIF... < /div>');
                return false;
            }
            else
            {
                $("#loading_image").html('<div class="loadm"><img src="../image / ajax - loader.gif "/></div>');//this is the loading image that is not showing.
                return true;
            }
        },
        onComplete: function(file, response){}
    });
});


var profileRefresh = function() {
    $.ajax({    
        type: "GET ",
        url: "picture ? target = refresh ",  
        success: function(response){ 
            $("#pro").html(response);
             setTimeout(profileRefresh, 3000); 
            $("#loading_image ").fadeOut('fast');// hide the loading image
        }
    });
};

1 个答案:

答案 0 :(得分:0)

做一件事。将加载图像保存在img标记中,如下所示

<img id="load" src="../image/ajax-loader.gif"/>

现在将其加载到您想要显示的位置

$("#loading_image").html($("#load").html());
相关问题