用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1271|回复: 0
收起左侧

[HELP] 关于AJAX 更新删除操作 分页

[复制链接]
发表于 2013-7-13 21:40:34 | 显示全部楼层 |阅读模式
控制器代码:
        public function userinfo()
        {
                $this->load->library('pagination');
                $num_rows=$this->tb_user->getall();
                $config['base_url'] = site_url()."/main/userinfo/";
                $config['total_rows'] = $this->tb_user->getall();
                $config['per_page'] = '20';
                /*省略一些配置*/
                $this->pagination->initialize($config);
                $data=array();
                $data['num_rows'] = $num_rows;
                $data['pagenation'] = $this->pagination->create_links();

                $arr['num']=$config['per_page'];
                $arr['offset']=$this->uri->segment(3)!==FALSE?$this->uri->segment(3)*$arr['num']-$arr['num']:0;
                $data['accounts'] = $this->tb_user->getAccounts($arr);//获取数据   
                $this->load->view('userinfo',$data);   //调用userinfo 视图
}

视图:js部分   
        $("input[name='freeze']").click(function(){ //冻结用户
                $.ajax({
                        type: "POST",
                        url: "<?php echo site_url()."/main/freeze";?>",
                        data: "id="+$(this).attr("id"),
                        success: function($msg){alert($msg);}
                });
        });

        $("input[name='delete']").click(function(){ //解除冻结
                $.ajax({
                        type: "POST",
                        url: "<?php echo site_url()."/main/delete";?>",
                        data: "id="+$(this).attr("id"),
                        success: function($msg){alert($msg);}
                });
        });

视图 html 部分

<?php
if (isset($accounts))
{
        foreach ($accounts as $a)
        {?>
                <tr align=center height=27>
                        <td width=12%><?php echo $a->id; ?></td>
                        <td width=12%><a href="#"><?php echo $a->name; ?></a></td>
                        <td width=12%><?php echo $a->pwd; ?></td>
                        <td width=12%><?php echo $a->freeze==0?"否":"是"; ?></td>
                        <td width=12%><?php echo $a->nickname; ?></td>
                        <td width=15%><?php echo $a->register_time; ?></td>
                        <td width=25%>
                                <input type="button" name="freeze" value="冻结用户" id="<?php echo "freeze".$a->id; ?>"/>
                                <input type="button" name="fire" value="解除冻结"   id="<?php echo "fire".$a->id; ?>"/>
                                <input type="button" name="delete" value="删除用户" id="<?php echo "delete".$a->id; ?>"/>
                        </td>
                </tr>
<?php
        }
}?>


求大师回复问题:
       超新手,准备弄一个用户管理系统,无非就是更新删除等等,弄了几天才实现更新删除数据库,然是,不能实现ajax的无刷新功能,要自己F5一下才行,一点思路都没有,都不知道怎么百度,求大师指点!

本版积分规则