Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 在不删除内容的情况下将其他网站中的元素获取到我的div中_Jquery_Ajax_Get - Fatal编程技术网

Jquery 在不删除内容的情况下将其他网站中的元素获取到我的div中

Jquery 在不删除内容的情况下将其他网站中的元素获取到我的div中,jquery,ajax,get,Jquery,Ajax,Get,我有一个带有div“content”和一些float元素的html页面(comp.html),在我的div下面有一个链接。将此链接(a#addphoto)推入我的div后,应插入另一个页面的div(#photo(boxes.html中的内容)。我该怎么做 html: 请帮帮兄弟们,我在jquery和Ajax方面真的很差我想你们需要这样的东西: $.ajax({ type: "GET",

我有一个带有div“content”和一些float元素的html页面(comp.html),在我的div下面有一个链接。将此链接(a#addphoto)推入我的div后,应插入另一个页面的div(#photo(boxes.html中的内容)。我该怎么做

html:


请帮帮兄弟们,我在jquery和Ajax方面真的很差

我想你们需要这样的东西:

                $.ajax({
                    type: "GET",
                    url: "http://www.google.be",
                    cache: false,
                    success: function(html){
                        $('.content').append(html);
                    }
                });
JQuery代码:

function loadSecond()
{
    $.get('second.html', function(data) {
          $('.content clearfix').html(data);
    });
}
HTML


1.
2.
3.
4.

现在还不完全清楚应该发生什么,您尝试了什么以及为什么不起作用。我应该将second.html中的div插入first.html的div class=“content clearfix”中second.html中的是什么?您尝试过Ajax吗?在第二个html-box.html:section id=“photo\u content”中有许多重复的类,如第一页class=“photo”谢谢,现在它可以工作了!
                $.ajax({
                    type: "GET",
                    url: "http://www.google.be",
                    cache: false,
                    success: function(html){
                        $('.content').append(html);
                    }
                });
function loadSecond()
{
    $.get('second.html', function(data) {
          $('.content clearfix').html(data);
    });
}
<div class="content clearfix">
     <div class="photo">1</div>
     <div class="photo">2</div>
     <div class="photo">3</div>
     <div class="photo">4</div>
</div>
<a href="#" id="addphoto" onclick="loadSecond()">Load Second.html</a>