编辑:这是新代码:
$("#normalcontent").hide("fast").load($this.attr("href") +" #normalcontent","",function(){
$(this).slideDown("normal");
$(this).find("img").each(function(){
if($(this).hasClass("large"))
{
var myThis=$(this);
myThis.css("display","none");
var img = new Image();
$(img).attr("src", "images/ajax-loader.gif");
$(img).css({
border:"none",
width:"16px",
height:"11px"
});
myThis.after(img);
myThis.load(function(){
$(img).remove();
myThis.fadeIn("normal");
})
.error(function(){
$(img).attr("src","images/errorIcon.png").css({
border:"none",
width:"14px",
height:"14px"
});
});
}
});
});
你好。
假设我在“index.php”中有一个链接,当我单击该链接时,它会通过 ajax 将页面“content.php”中的内容加载到“index.php”中的 div 元素中,该元素具有“#content”的ID。“content.php”中的内容有大图像。我想显示一个图像加载器,比如“ajax-loader.gif”,而不是那些大图像,直到客户端下载图像。
(我知道如何为“index.php”上的图像创建一个图像加载器 .gif。)
我怎样才能做到这一点?