weixin_33726313 2013-11-16 07:48 采纳率: 0%
浏览 32

评论删除无效

I'm trying to perform a delete of a forum comment using Jquery AJAX and PHP(codeigniter) with Datamapper but for some reason no matter what I do nothing happens when I click delete.

If anyone can see the problem that'd be great.

Jquery =

$('button.delete').on('click', function(event) {

    console.log('derp');
    // var comment = $(this).parent('.comment').attr('id');

    // $.post('actions/delete_comment/'+comment);

});

forum post php =

<li class="comment" id="<?=$comment->id ?>">
    <img  src="assets/img/avatars/<?=$comment->user.'.jpg' ?>">
    <p class="username"><?=$comment->user ?></p><p class="commenttime"><?=$comment->date ?></p><br>
    <p><?=$comment->contents ?></p>
    <button class="delete">Delete</button>
</li>

delete php =

public function delete_comment($id){
    $comments = new Forum_comment;
    $comments->get_where(array('id' => $id));
    $comments->delete();
}
  • 写回答

4条回答 默认 最新

  • weixin_33721427 2013-11-16 07:50
    关注

    You commented out all of the actual code in your jQuery event, except for the console.log()

    $('button.delete').on('click', function(event) {
    
        console.log('derp');
        var comment = $(this).parent('.comment').attr('id');  // Remove leading slashes
    
        $.post('actions/delete_comment/'+comment);  // Remove leading slashes
    
    });
    

    Of course nothing happens!

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器