我有一个获取和回显状态更新的 while 循环。我试图在我的 while 循环中回显一个“REPOST”链接,以便它附加到任何状态更新(位于它下方),并在单击时将 ID 传递给外部 .php 文件。这个链接是 jquery+ajax。
<script type="text/javascript">
$(document).on('click', 'a[id^=repost]', function(){
var thePostID = $(this).prop('id').split('-')[1];
//this now has the id of the $row['id'] we declared earlier.
$.ajax({
url: 'reposthandler.php',
type: 'POST',
data: {'id' : thePostID},
success: function(data){
}
});
});
</script>
<?php
include ('time.php');
$query = "SELECT poster, posterpic, category, type, date, id, follow.beingfollowed
FROM usergen LEFT JOIN follow ON follow.beingfollowed = usergen.poster WHERE
follow.iwannafollow
= '*".$loggedin."' ORDER BY usergen.date DESC ";
$result = mysql_query($query) or die(mysql_error()) ;
$rows = array();
while($row = mysql_fetch_array($result)) {
$row['ago'] = ago($row['date']);
$rows[] = $row;
echo '<br />';
echo '<img src="' . $row['posterpic'] . '" width="40px" height="50px">';
echo '<font color="red" size=2px><i>';
echo '<a>'.$row['poster'].'</a></i></font>';
echo '<br />';
echo $row['category'] . ' for ' . $row['type'] . ' (' . $row['ago'] . ')';
echo '<a href="#" id="repost-',$row['id'],'">REPOST</a>';
echo '<br /><br /><HR size="4" width="auto" color="white">';
}
echo '</div>';
?>
链接是死的,不链接到任何东西。为什么是这样?我是否需要在“成功:函数(数据)”下方添加一些内容?