动态加载div

时间:2013-09-19 15:25:07

标签: javascript php jquery html ajax

是否将数据库信息加载并显示到div上?我在这里有这个代码

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<title></title>
<link rel='stylesheet' href='assets/style.css' />
</head>
<?php include('includes/bootstrap.php'); ?>
<body>
<div id='box' class='hidden'>
    <div id='box_menu'>
        <div class='close_box' id='close_this_box'>X</div>
        <div id='box_content'></div>
    </div>
</div>
<?php
$sql = "SELECT * FROM stars_info";
$que = $db->prepare($sql);
try{$que->execute();
    while($row = $que->fetch(PDO::FETCH_BOTH)) {
        echo
            "<a href='#' id='{$row['link_name']}' class='click' >".
            "<div style='position: absolute; top: {$row['top']}px; left: {$row['left']}px;'></div></a>\n";
    }
} catch(PDOException $e){ $e->getMessage(); } 
?>
</body>
</html>
<script type='text/javascript'>
$(document).ready(
    function() {
        $('.click').hover(function() {
            $('#box_content').load('content.php');
            $('#box').removeClass('hidden')
        });
    }
);
$('#close_this_box').click(function(){
    $('#box').addClass('hidden')
});
</script>

但我无法弄清楚如何将链接中的信息传递给content.php然后显示它。有人可以帮帮我吗?

0 个答案:

没有答案