0
我有一個文件上傳按鈕,通過ajax上傳文件,我通過每3秒發送一次ajax請求顯示上傳的圖片,問題是,我想顯示一個加載圖像,每當用戶點擊上傳按鈕並將其隱藏在成功上,但圖像未顯示。如上所述,我有另一個Ajax調用來獲取上傳的圖片,我認爲它隱藏了圖片。所以我想要的只是當用戶點擊按鈕顯示加載圖像時,然後當第二次Ajax調用將上傳的圖像顯示回給用戶時,隱藏圖像。有人可以給我提示嗎?加載圖像不顯示jquery
$("#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
}
});
};
你想設置或獲取圖像? –
@Soombinakundi直到上傳的圖像通過第二個Ajax調用顯示回給用戶,並繼續顯示加載圖像。 – user3412305