Php 从缓存加载动态生成的图像
您好,当图像上传到服务器时,我有一个回调函数,然后我想将该图像显示为PHP脚本生成的缩略图Php 从缓存加载动态生成的图像,php,jquery,caching,Php,Jquery,Caching,您好,当图像上传到服务器时,我有一个回调函数,然后我想将该图像显示为PHP脚本生成的缩略图 'onComplete' : function(event, ID, fileObj, name,response, data) { var newfile = '/admin/includes/image.php?filename='+name+'&maxw=150'; $('#uploaded_images').append('<li class
'onComplete' : function(event, ID, fileObj, name,response, data) {
var newfile = '/admin/includes/image.php?filename='+name+'&maxw=150';
$('#uploaded_images').append('<li class="'+ID+'"><img src="/site_images/ajax-loader.gif"" alt="" /></li>').fadeIn('fast');
$.get(newfile, function(){
$('.'+ID).fadeOut().empty();
$("."+ID).append('<img src="'+newfile+'" alt="" />').fadeIn();
});
'onComplete':函数(事件、ID、fileObj、名称、响应、数据){
var newfile='/admin/includes/image.php?filename='+name+'&maxw=150';
$(“#上传的_图像”).append(“).fadeIn('fast');
$.get(新文件,函数(){
$('.+ID).fadeOut().empty();
$(“+ID).append(“”).fadeIn();
});
“.get”jquery函数应该仅在图像加载后显示img标记(确实如此)。问题是,当我打印img标记时,图像会再次加载。这实际上只会在图像的“容器”中淡出。图像只会在加载时继续显示,并且不会产生任何效果。
是否有一种方法可以安排脚本使用带有“get”的缓存图像,或者仅在直接加载图像时才打印所有内容
谢谢请使用图像的事件,而不是,如下所示:
$("<img />").load(function() {
var img = this;
$('.'+ID).fadeOut(function() { $(this).html(img); }).fadeIn();
}).attr("src", newfile);
$(“
当我们创建的图像元素完成加载后,淡出.ID
元素,淡出完成后,将内容设置为
元素(是.empty().append()
)的快捷方式),然后淡入。@Sandro-它创建了一个图像元素,使浏览器能够获取它:)您好,它工作得很好,但我仍在尝试理解它,因为我总是在页面中已经存在的元素中使用load()。如果在该元素之后添加了属性src,那么图像如何显示fadeIn?