阿贾克斯附加负载 [英] Ajax append load

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

问题描述

它必须是jQuery的

我的文件text.html 6格在(A,B,C,D,E,F)

在另一个文件中,我有一个div,我喜欢它来填充A + B + C + D + E +内容˚F成单一的div

我已经尝试.load =,但是B remplace一个 我已经尝试追加,但我需要一个临时VAR

所以现在我被困

这code从文件textes.html ... DIV#A的内容并把内容放到股利#right,但第二libe REMPLACE右一,右b

内容

我想追加内容A + B NOT A对B

  $(文件)。就绪(函数(){
变种临时=负载('textes.html #nicolas');
$('#右)追加(TEMP)。
变种临时=负载('textes.html #antoine');
$('#右)追加(TEMP)。
。
。
。
。

返回false;
});
 

这code是背后究竟应该工作的想法,但我不能让一个AJAX .load()将内容加载到一个变量,将内容附加到div ...

 <脚本类型=文/ JavaScript的>
$(文件)。就绪(函数(){
$阿贾克斯({
  网址:textes.html
  缓存:假的,
  成功:函数(HTML){
    $(#右)追加(HTML)。
  }
});
});
< / SCRIPT>
 

这code加载整个HTML文件,我想只得到某些选定DIV#

解决方案

  $(文件)。就绪(函数(){
    $获得(textes.html功能(数据){
        $(#右)追加($(#尼古拉斯,数据))结束()追加($(#安托万,数据))。;
    },HTML);
});
 

it must be jquery

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

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

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

so now i am stuck

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

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;
});

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>

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');    
});

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

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