Say I have like:

说我喜欢:

$(function() {
    $('a').click(function(e) {
        e.preventDefault();
        var h = $(this).attr('href');
        $('#content').load(h);
    });
});

That actually doesn't load the images as well it just loads the content, how do you go about loading the actual images too?

这实际上并没有加载图像,只是加载内容,你如何加载实际的图像呢?

Some people didn't seem to understand: what I mean is it does load the images but doesn't 'preload' thus meaning you witness the images load individually.

有些人似乎并不理解:我的意思是它确实加载了图像但没有“预加载”,因此意味着您可以看到图像单独加载。

Edit: Say the href was equal to somepage.html and that page had images on it as well as content, yes it would load the images and the content but it doesn't actually preload the images at all, you're still witnessing the images load individually. How would one go about preloading the images in the request itself?

编辑:假设href等于somepage.html,该页面上有图像和内容,是的,它会加载图像和内容,但它实际上并没有预先加载图像,你仍然在见证图像单独加载。如何在请求本身中预加载图像?

2 个解决方案

#1


5

Try this:

尝试这个:

  1. Hide the #content div, and call load on it. This will load the content invisibly so your users don't see the images load afterwards
  2. 隐藏#content div,并在其上调用load。这将无形地加载内容,因此您的用户之后不会看到图像加载
  3. Bind load event handlers on each image, and when they have all fired, re-show the #content div
  4. 在每个图像上绑定加载事件处理程序,当它们全部触发时,重新显示#content div

See this answer for reference: Know when images are done loading in AJAX response. It will show you exactly what to do.

请参阅此答案以供参考:了解何时在AJAX响应中加载图像。它会告诉你到底该做什么。

更多相关文章

  1. 页面加载后的JQuery(窗口).load?
  2. 获取背景图像的最终大小
  3. 如何将加载微调器图像添加到jquery选项卡中的每个选项卡?
  4. ajax cache false无法加载图片
  5. jQuery - 加载gif的延迟显示
  6. Ajax/jQuery -在页面加载时将网页内容加载到div中?
  7. 点击JSON数据加载Galleria画廊。我需要新鲜的眼睛来看我的错误
  8. 在执行ajax时显示加载图像
  9. jQuery实例(ajax通信和动态加载二级菜单)

随机推荐

  1. 第四章C++:表达式概念-运算符的应用
  2. 如何看待C#中的out和ref?探讨它们之间的区
  3. 第三章C++:字符串string、向量vector和数
  4. 基于汇编的 C/C++ 协程(用于服务器)的实现
  5. 第二章C++:变量和基本类型
  6. (C++)错误的map删除操作和STL中容器的迭代
  7. 第一章C++:函数返回值、GNU编译器命令
  8. 案例分享c++ map的使用和 查找性能测试
  9. C++引用的意义与引用的本质
  10. 从事C/C++开发多年,给零基础想学习C/C++的