是否有可能返回一个特定的div的整个数据和innerhtml或我必须遵循不同的方法..我如何显示数据到popover div。jquery ajax返回HTML元素
的代码片段低于 我只发送一个伪值作为“4”只是为了检查,
account.php
在该页面我使用的酥料饼的显示内容处理通过AJAX
<a id="popover" href="#" data-trigger="hover" rel="popover" ><img class="img-thumbnail" src="../xxx/xxx/abc.jpg" width="50"/></a>
<div id="popajax">
</div>
jQuery的
<script type="text/javascript">
$(function()
{
$("#popover").mouseover(function()
{
var textcontent = '4';
$.ajax({
type:'GET',
url: "/getuserdetails.php",
data: {myval:textcontent},
cache: true,
error: function(){
alert ("ERROR");
},
success: function(html)
{
$("#popajax").after(html);
}
});
return false;
});
});
</script>
酥料饼的脚本
<script>
$(function() {
$("#popover").popover({ trigger: "hover",
html: true,
placement : 'top',
content: function() {
return $('#popover_content').html();
},
title: function() {
return $('#popover_title').html();
}
});
});
</script>
getuserdetails.php
<?php session_start();
include('include/functions.php'); /* This is for crud and other functions*/
if(isset($_GET['myval']))
{
$sql = sql::readOne("SELECT * FROM table_name WHERE id='$_GET[myval]'");
}
?>
<div id="popover_title" class="hide" >
<h4><?php echo $sql[0]->username ?></h4>
</div>
<div id="popover_content" class="hide" >
<div> <p> This is Atul Joshi</p></div>
</div>
*像这样