因此,我提出了AJAX请求,它可以很好地提交并按预期成功返回HTML-但是在返回到目标div元素的HTML中,它具有一个按钮。我已经在其中添加了jQuery,即单击它时将隐藏AJAX成功中的HTML。
简而言之:我希望关闭按钮可以关闭div,但似乎不起作用。
$('#user_report__dd #make_report').click(function(){
var interaction_type = $(this).data('interaction_type');
var user_id = $(this).data('user_id');
$.ajax({
type: 'POST',
dataType: 'html',
url: ajax_url,
data: {
interaction_type: interaction_type,
user_id: user_id,
},
success:function(html){
// $('.ajax_call').html(html);
$('.ajax_call').html(html);
// stop body from scrolling
}
});
});
Run Code Online (Sandbox Code Playgroud)
if(isset($_POST['interaction_type']) && $_POST['interaction_type'] == 'report_user'){
global $report;
$report->Form($_POST['user_id'], 'user');
// This returns the HTML
}
Run Code Online (Sandbox Code Playgroud)
然后在我的主要jQuery文件中
$('.close').click(function(){
$(this).parents('.pulled_in_html');
});
Run Code Online (Sandbox Code Playgroud)