weixin_33744141 2010-10-28 17:04 采纳率: 0%
浏览 52

通过AJAX加载更多文件

Is it somehow possible to load more files via AJAX?

Example

$.ajax({
  url: ["test1.html", "test2.html", "test3.html"],
  success: function(data1, data2, data3) {
    // Do something  
  }
});

Because I would like to avoid callbacks...

  $.ajax({
  url: "test1.html",
  success: function(data) {

    $.ajax({
      url: "test2.html",
      success: function(data) {

        $.ajax({
          url: "test3.html",
          success: function(data) {

            // Do something

          }
        });

      }
    });

  }
});
  • 写回答

6条回答 默认 最新

  • weixin_33701617 2010-10-28 17:08
    关注

    Yes, it is. You just can't load full HTML structures (with BODY elements and such) - you need to use HTML snippets.

    You can then e.g. inject the loaded data into a div element:

    success: function(data) 
     { $("#div_id").html(data); }
    

    jQuery also has the almost decadently lazy .load() shortcut:

    $('#div_id').load('ajax/test.html');
    
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器