helloxielan 2015-09-19 10:42 采纳率: 0%
浏览 34

jQuery ajax加载问题

JQUERY:

$.ajax
({
   url: 'b.html',
    success: function(data, textStatus, XMLHttpRequest)
    {
      $('#content').html($('#content', data).html());
    }
});

HTML:

<html>
 <body>
   <div id="content">
     <script type='text/javascript' src="xx.js"></script>
     <link rel="stylesheet" href="xx.css" type="text/css"/>
    <div>
        <img src="xxxxxxxxxx.jopg">
    </div>
  </div>
  </body>
</html>

how to know,a.html

$('#content').html($('#content', data).html());
  • 写回答

1条回答 默认 最新

  • weixin_33711641 2015-09-19 10:57
    关注

    First off, you wouldn't do that, but I'll assume you just whipped that up for the purpose of asking your question.

    Couple of options come to mind:

    • use the setInterval function to keep checking every X milliseconds e.g. setInterval(function(){ /* check for elements here */ }, 500);

    • use window.performance.getEntriesByType("resource") to determine if all the resources you want have been downloaded. Again, this would probably be inside a setInterval.

    If you simply loaded the b.html to begin with, using $(document).ready(function() { /* everything has now loaded*/ })); would be the answer.

    评论

    报告相同问题?

    悬赏问题

    • ¥15 PMM 9010/30P
    • ¥15 pom文件依赖管理,未找到依赖
    • ¥15 现在后端返回给我一堆下载地址,都是一个视频切片后的,如何在uniapp安卓环境下将这些分片的视频下周并且合并成原始视频并下载到本地。
    • ¥15 Unity导出2D项目运行时图片变成马赛克
    • ¥15 关于communitytoolkit.mvvm的生成器得到的代码看起来没有被使用的问题
    • ¥15 matlab中此类型的变量不支持使用点进行索引
    • ¥15 咨询第六届工业互联网数据创新大赛原始数据
    • ¥15 Pycharm无法自动补全,识别第三方库函数接收的参数!
    • ¥15 STM32U575 pwm和DMA输出的波形少一段
    • ¥30 android百度地图SDK海量点显示标题