Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/452.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
Javascript 使用ajax加载popover内容无法正常工作_Javascript_Jquery_Ajax_Twitter Bootstrap - Fatal编程技术网

Javascript 使用ajax加载popover内容无法正常工作

Javascript 使用ajax加载popover内容无法正常工作,javascript,jquery,ajax,twitter-bootstrap,Javascript,Jquery,Ajax,Twitter Bootstrap,我使用ajax调用在我的页面中的弹出窗口中显示不同产品的show方法内容 我使用以下代码: function details_in_popup(link, div_id){ $.ajax({ url: link, success: function(response){ $('#'+div_id).html(response); } }); return '<div id="'+ div_id

我使用ajax调用在我的页面中的弹出窗口中显示不同产品的show方法内容

我使用以下代码:

function details_in_popup(link, div_id){
    $.ajax({
        url: link,
        success: function(response){
            $('#'+div_id).html(response);
        }
    });
    return '<div id="'+ div_id +'">Loading...</div>';
}

$(function () {
  $('[data-toggle="popover"]').popover({
    "html": true,
    "title": '<span class="text-info"><strong>title</strong></span>'+
            '<button type="button" id="close" class="close" >&times; </button>',
    "content": function(){
        var div_id =  "tmp-id-" + $.now();
        return details_in_popup($(this).data('url'), div_id);
    }


  }).on('shown.bs.popover', function(e){
  var popover = jQuery(this);
  $('body').on('click','.close', function(e){
    popover.popover('hide');
  });
 });
});
我遇到的问题是,第一次打开popover时,内容被正确填充,第二次,我在popover中获得了重复的标题,然后第三次,来自第一个popover和第二个popover的内容被完全混淆

这就像以前的popover从未被清理,每次我打开一个新的popover时都会累积起来一样

代码中是否有明显的东西可能导致此问题

谢谢

在ajax成功时使用重置div


然后附加响应。

我想建议$+div\u id.empty.htmlresponse,他们可以两种都尝试。谢谢你的帮助!但这并没有解决我的问题。。。我尝试了这两种方法,但对我的行为没有任何影响……你是如何打开弹出窗口的?
$('#'+div_id).text('');