【发布时间】:2015-05-19 22:06:38
【问题描述】:
我需要一些帮助,我有一个数据库:“ID | PLZ | Country | Author | Comment”
使用 Jquery,我设法显示/隐藏“评论”字段。
现在我尝试用 ajax onclick 加载评论,所以如果你点击“显示 cmets”按钮,ajax 应该从特定 id 加载评论。
我知道我还需要更改 jquery 代码以从正确的 id 获得正确的评论,但我不知道该怎么做。
这是我的代码:
查询:
$(document).ready(function(){
$(".productDescription").hide();
$(".show_hide").show();
$(".hide_show").hide();
$('.show_hide').click(function(){
$(this).parent().find('.productDescription').slideToggle();
$(this).parent().find(".show_hide").hide();
$(this).parent().find(".hide_show").show();
});
$('.hide_show').click(function(){
$(this).parent().find('.productDescription').slideToggle();
$(this).parent().find(".show_hide").show();
$(this).parent().find(".hide_show").hide();
});
});
</script>
PHP:
<?php
$abfrage = "SELECT * FROM ufo";
$ergebnis = mysql_query($abfrage);
while($row = mysql_fetch_object($ergebnis))
{
echo '
<div class="product clearfix">
<h4>ID:'.$row->id.'|PLZ:'.$row->PLZ.'|Country:'.$row->Country.'</h4>
<a href="#" class="show_hide">Show Comments</a>
<a href="#" class="hide_show">Hide Comments</a>
<div class="productDescription">
<p>Comment:'.$row->Comment.'</p>
</div>
</div>
<br>';
}
?>
如果有人可以帮助我,我将不胜感激。
久违了
【问题讨论】: