我需要一些帮助在这里,我已经有一个数据库:我设法显示/隐藏“注释”字段“ID | PLZ |国家| |作者评论”阿贾克斯负荷“评论”的onclick
使用jQuery。
现在我试着用ajax onclick加载评论,所以如果你点击“显示评论”按钮,ajax应该从特定的ID加载注释。
我知道我需要更改jquery代码以从正确的id获得正确的评论,但我不知道该怎么做。
继承人我的代码:
JQUERY:
$(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>';
}
?>
我会很感激,如果有人可以帮助我。
只要
嘿,那里,谢谢你的回复,我现在有调用一个.php文件,提取评论?实时演示:http://www.twitch-smileys.com/ufo/ –
是的,基本上你可以通过url调用一个php方法,并在该php中调用数据库。我不熟悉PHP,所以不能帮助你构建它,但我确信网络上有很多例子。 – mattfetz
好吧,我会尽力,非常感谢!其他建议表示赞赏 –