dovzrfr0506 2010-09-20 17:32
浏览 36
已采纳

这个jquery帖子没有显示html?

im trying to load more data(like pagintaion) using jquery. my ajax is working, but jquery is not displaying the data the way i want it, this is my code,

jquery file:

$(function () {
    //More Button
    $('.more').live("click", function () {
        var ID = $(this).attr("id");
        if (ID) {
            $("#more" + ID).html('<img src="moreajax.gif" />');
            $.ajax({
                type: "POST",
                url: "ajax_more.php",
                data: "lastmsg=" + ID,
                cache: false,
                success: function (html) {
                    $("ul#statuses").append(html);
                    $("#more" + ID).remove();
                }
            });
        }
        else {
            $(".morebox").html('The End');
        }
        return false;
    });
});

this is the html file: this is the button thats clicked to retrieve more results!

echo'<div id="more'. $dateTime.'" class="morebox">
    <a href="#" class="more" id="'.$dateTime.'">more</a>';

and finally the ajax_more.php file:

<?php session_start();
include("includes/connect.php");
include("includes/functions.php");


if(isset($_POST['lastmsg']))
{
$lastmsg=$_POST['lastmsg'];

$result="SELECT u.username, u.picture, m.id, m.user_note, m.reply_id, m.reply_name, m.recycle_id, m.recycle_name, m.dt
FROM relationships r, notes m, user u
WHERE m.user_id = r.leader
AND r.leader = u.user_id
AND r.listener =2
UNION
SELECT username, picture, id, user_note, reply_id, reply_name, recycle_id, recycle_name, dt
FROM user u, notes b
WHERE u.user_id = b.user_id
AND b.user_id =2
AND dt < '$lastmsg'
ORDER BY dt DESC
LIMIT 10 ";


$query= mysql_query($result) or die(mysql_error().$result);
while($row=mysql_fetch_array($query))
{
// echo the posts
   echo formatUpdate($row['user_note'],$row['dt'],$row['picture'],$row['username'],$row['id'],$row['reply_id'],$row['reply_name'],$row['recycle_id'],$row['recycle_name']);

}


?>

<div id="more<?php echo $row['dt']; ?>" class="morebox">
<a href="#" id="<?php echo $row['dt']; ?>" class="more">more</a>
</div>

<?php
}
?>

P.S i checked firebug and ajax_more.php is returning the results data back that i wanted, but on the frontend jquery is not showing it!!

  • 写回答

1条回答 默认 最新

  • duancunsu9209 2010-09-20 17:59
    关注

    When referencing classes with jQuery selectors (and CSS selectors) prepend the class name with a . e.g., 'ul.statuses'. When referencing ids use # e.g., 'ul#statuses'. Also it is best practice in jQuery to drop the tag in front of id selectors so if you reference an id in a selector it should look like this: '#statuses'

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元