我正在使用数据表,这是我的一些用于获取数据表数据的代码,现在我可以正常工作,当有人悬停或点击锚标记时加载动态内容...这个图像{ {3}}
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;
}
这是我试过的,仍然是引导程序弹出窗口无法正常工作
$('.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;
}
这是我用于我的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;
}
修改 这是我对代码datatables data
的参考