HTML 内にボタンがあり、それをクリックすると、PHP ファイルでクエリを実行し、結果をエコーする必要があります。
次のことを試しましたが、ボタンをクリックしても何もしません。どうしたの?
HTML/アヤックス:
<?php
$reply_id = 15;
?>
<html>
<body>
<center><a class="btn show-more">Show more comments</a></center>
<div id="resultcomments"></div>
<script type="text/javascript">
var id = $reply_id;
$(document).ready(function() {
$(".show-more").click(function() {
$.ajax({
url: 'assets/misc/test.php',
type: "POST",
data: ({id_variable: id}),
function(data) {
$("#resultcomments").html(data);
}
});
});
});
</script>
</body>
</html>
PHP (assets/misc/test.php にあります):
<?php
$replyid= $_POST['id_variable'];
echo $replyid;
// query would go here
?>