加载图片没有显示jquery

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

$("#loading_image").html('
//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('
Sorry, you can only upload the following file formats : JPG, JPEG, PNG and GIF...
'); return false; } else { $("#loading_image").html('
');//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 } }); };

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

  

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

 $("#loading_image").html($("#load").html());