如何让jQuery .load()在容器中追加返回的数据而不是重写它?

Amr*_*rhy 1 html javascript model-view-controller jquery

我正在使用.load()函数从控制器动作加载html内容并放入现有的容器元素,问题是来自load方法的这些数据将删除此容器中的所有内容,然后在那里写入新数据,我是什么想要保留此容器中的任何内容,只需附加即将到来的数据.

这是我的负担:

$("#container").load("/Profile/Chat", { friendId: friendId });
Run Code Online (Sandbox Code Playgroud)

She*_*hef 5

$.get("/Profile/Chat", { friendId: friendId }, function(html){
    $("#container").append(html);
}, 'html');
Run Code Online (Sandbox Code Playgroud)