且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 ajax、php 和 jQuery 更改 DIV 内容

更新时间:2023-12-05 11:06:22

<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 事件

And add onclick event in your lists

<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>