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 关于推送项目到github的问题
  • ¥15 急!C++指针编写相关的问题
  • ¥30 用python写一个多签情况下波场的代理资源和回收资源
  • ¥15 怎么在matlab中输出显示泵的流量-扬程和管路损失与流量均在一个表格里
  • ¥15 matlab学期例题代码答疑
  • ¥50 Hadoop:好友推荐
  • ¥15 在线手电筒追加按钮JS
  • ¥15 调用函数时,无关变量的改变引起函数值的改变
  • ¥15 xy坐标转化为经纬度坐标
  • ¥15 一般三角模糊数的上界值和下届值取中值的多少比较合理?