在bootstrap popover中加载动态内容

im using datatables, and this is my some of my code for fetching the data for datatables, this works fine now what i want is to load dynamic content on when someone hover or click the anchor tag... this the image datatables data

foreach($result as $row)
{
    $sub_array = array();
    $sub_array[] = '<a href="#" class="hover" id="'.$row['id'].'">'.clean($row["f_name"])." ".clean($row["m_name"])." ".clean($row["l_name"]).'</a>';
    $sub_array[] = strtoupper($row["sex"]);
    $sub_array[] = $row["birthdate"];
    $sub_array[] = $row['age'];
    $data[] = $sub_array;
}

this is what i have tried, still the bootstrap popover not working

$('.hover').popover({
      title:fetchData,
      html:true,
      placement:'right'
    });

    function fetchData(){
      var fetch_data='';
      var element = $(this);
      var id = element.attr("id");

      $.ajax({
        url:"../controller/fetch_single.php",
        method:"POST",
        async:false,
        data:{id:id},
        success:function(data){
          fetch_data = data;
          alert(data);
        }
      });
      return fetch_data;
    }

this is the code that i used for my ajax

//fetch_single.php
    if(isset($_POST["id"]))
    {
        $output = '';
        $statement = $connection->prepare(
            "SELECT id, sex, f_name, m_name, l_name, birthdate,image_name,house_num,street TIMESTAMPDIFF(YEAR, birthdate, CURDATE()) as age from rec_personal WHERE id='".$_POST['id']."'"
            );
        $statement->execute();
        $result = $statement->fetchAll();

        foreach ($result as $row) {
            $output = '
                <p><img src="../upload/'.$row["image_name"].'" class="img-responsive img-thumbnail" /></p>  
                <p><label>Name : '.$row['f_name'].'</label></p>  
                <p><label>Address : </label><br />'.$row['house_num'].'</p>  
                <p><label>Gender : </label>'.$row['sex'].'</p>  
                <p><label>Age : </label>'.$row['age'].' Years</p>  

            ';
        }
        echo $output;
    } 

EDIT this is my reference for the code http://www.webslesson.info/2016/11/php-ajax-jquery-load-dynamic-content-in-bootstrap-popover.html

duanqiang5722
duanqiang5722 还是行不通:(
2 年多之前 回复
doulian4467
doulian4467 尝试将data-toggle=“popover”添加到<a>标记。
2 年多之前 回复
down00112
down00112 当我点击锚标签时,弹出窗口不起作用
2 年多之前 回复
duanpaotian2348
duanpaotian2348 对ajax没有响应,控制台上没有错误..
2 年多之前 回复
duanan5940
duanan5940 你调试过吗?你的成功函数会得到什么回报?
2 年多之前 回复
dth8312
dth8312 ajax没有响应,根本没有错误
2 年多之前 回复
dqk77945
dqk77945 单击或悬停锚标记时没有错误
2 年多之前 回复
doumibi6899
doumibi6899 你有任何错误吗?
2 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐