Ajax 追加加载 [英] Ajax append load

查看:39
本文介绍了Ajax 追加加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

必须是jquery

我在 (a,b,c,d,e,f) 中有 6 个 div 的文件 text.html

I have file text.html with 6 div in (a,b,c,d,e,f)

在另一个文件中,我有一个 div,我喜欢将 a+b+c+d+e+f 的内容填充到单个 div 中

In another file i have a div, i like it to populate the content of a+b+c+d+e+f into that single div

我尝试过 .load = 但 b 替换 a我尝试追加,但我需要一个临时变量

I have try .load = but b remplace a i have try append, but i need a temp var

所以现在我被卡住了

该代码从文件 textes.html ... div #a 中获取内容并将内容放入 div #right,但第二个 libe 将右 a 的内容替换为右 b

That code get the content from the file textes.html ... div #a and put the content into div #right, but the second libe REMPLACE the content of right a with right b

我喜欢将内容 a + b 附加到 b 上,而不是 a

I like to append the content a + b NOT a over b

$(document).ready(function(){
var temp = load('textes.html #nicolas');
$('#right').append(temp);
var temp = load('textes.html #antoine');
$('#right').append(temp);
.
.
.
.

return false;
});

该代码是什么应该工作背后的想法,但我不能使 ajax .load() 将内容加载到变量中以将内容附加到 div...

that code is the idea behind what should work, but i cannot make a ajax .load() to load content into a variable to append the content to the div...

<script type="text/javascript">
$(document).ready(function(){    
$.ajax({
  url: "textes.html",
  cache: false,
  success: function(html){
    $("#right").append(html);
  }
});
});
</script>

该代码加载整个 html 文件,我喜欢只获取一些选定的 DIV #

That code load the WHOLE html file, i like to get only some selected DIV #

推荐答案

$(document).ready(function(){    
    $.get("textes.html",function(data){
        $("#right").append($("#nicolas",data)).end().append($("#antoine",data));
    },'html');    
});

这篇关于Ajax 追加加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆