是否有可能返回一個特定的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>
*像這樣