加载图片没有显示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());
Interesting Posts
使用“application / json;将ajaxpost发送到mvc; charset = utf-8“从vs web开发人员服务器返回错误500
使用jQuery检查链接是否仍然有效
在动态加载的内容上使用hammer.js
ASP.NET MVC 3 LoadingElementDuration无法正常工作?
jquery Ajax Request SyntaxError:意外的令牌<
jQuery AJAX调用中的内存泄漏
在$ .ajax成功中迭代JSON
window.location.href在IE 11中不起作用
AJAX + SEO快速提问
如何比较两个值,如果匹配jquery循环中的任何值,则追加它