我有一个div,其中包含数据库的一些文本:
<div id="summary">Here is summary of movie</div>
以及链接列表:
<a href="?id=1" class="movie">Name of movie</a> <a href="?id=2" class="movie">Name of movie</a> ..
该过程应如下所示:
<script> function getSummary(id) { $.ajax({ type: "GET", url: 'Your URL', data: "id=" + id, // appears as $_GET['id'] @ your backend side success: function(data) { // data is ur summary $('#summary').html(data); } }); } </script>
并onclick在您的列表中添加事件
onclick
<a onclick="getSummary('1')">View Text</a> <div id="#summary">This text will be replaced when the onclick event (link is clicked) is triggered.</div>