jQuery Ajax基于Ajax函数在索引页中隐藏Div ID


jQuery Ajax Hide Div ID in index page based on Ajax function

index.php

$('.report_posts').live("click",function() 
{
     $.ajax(
     type: "GET",
     url: "mini_report_post.php",
     data: 'post_id=' + ID,
     success: function (data)
     });
});
<div id="stbody<?php echo $post_id; ?>">
</div>

mini_report_post.php

$(".btn_report").click(function() 
    {
        var ID = $(this).attr("id");
        var uid_modal = $("#uid_modal").val();
        var my_uid = $("#my_uid").val();
        var dataString = 'uid_modal='+ uid_modal +'&my_uid='+ my_uid;
            $.ajax(
            {
                type: "POST",
                url: "update_block_user.php",
                data: dataString,
                cache: false,
                success: function(html)
                {
                    $("#stbody"+ID).fadeOut();
                    $('.modal').modal('hide');
                }
            });
        return false;
    });
<button id="<?php echo $post_id; ?>" class="btn_report"/>

我想在SuccessAjax函数之后隐藏$("#stbody"+ID).fadeOut();,但它不起作用。stbody不会褪色。我尝试了上面的代码,但仍然不能知道吗?

尝试更改mini_report_post.php 中的代码

您的代码::$(".btn_report").click(function()

替换为:jQuery(document).on('click','.btn_report', function(){