首页 > 解决方案 > 如何在 ajax 回调后重新加载 div,而该 div 中没有特定类

问题描述

是否可以在 ajax 调用后重新加载 div,而该 div 中没有特定类?我有一个带有类的 div comments,我想在 ajax 调用后重新加载它。类mediamodal由 foreach 循环生成。

<div class="comments">

    <div class="media">
       some content here
    </div>
    <div class="modal">
       content of modal
    </div>

    <div class="media">
       some content here
    </div>
    <div class="modal">
       content of modal
    </div>

    <div class="media">
       some content here
    </div>
    <div class="modal">
       content of modal
    </div>

</div>

我的阿贾克斯:

success: function(data) {
    $('.result').html(data);        
    $(".comments").load(" .comments > *"); // reload div comments 

},

所以我正在寻找类似的东西:

$(".comments").load(" .comments > *"); // reload div comments except the classes .modal in that div

标签: jqueryajaxcallbackreload

解决方案


https://www.quora.com/How-can-we-refresh-a-DIV-without-reloading-the-whole-page 或者我只是复制这个

 $("#divToReload_WithDAta").load(location.href + " #divToReload_WithDAta");

推荐阅读