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 在若依框架下实现人脸识别
  • ¥15 网络科学导论,网络控制
  • ¥100 安卓tv程序连接SQLSERVER2008问题
  • ¥15 利用Sentinel-2和Landsat8做一个水库的长时序NDVI的对比,为什么Snetinel-2计算的结果最小值特别小,而Lansat8就很平均
  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同