码迷,mamicode.com
首页 > Web开发 > 详细

ajax 删除/修改单条数据

时间:2017-03-12 19:30:48      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:hone   success   json   code   rip   turn   blog   color   his   

ajax代码

<script>
$(".onedel").click(function(){ if (!confirm("确认要删除?")) { window.event.returnValue = false; }else { var id = $(this).attr("data-id"); $.ajax({ url: "{:U(‘Phone/ajaxOnedel‘)}", type: "post", dataType: "json", data: {id: id,table:‘email_p‘}, success: function (data) { if (data.id == 1) { alert("删除成功"); window.location.href=("{:U(‘Phone/remail‘)}"); } } }) } });
</script>

控制器函数代码

public function ajaxOnedel(){
        $table = I("post.table");
        $map[‘readers‘] = $_SESSION[‘login‘];
        $map[‘emailid‘] = I(‘post.id‘);
        $data[‘statuss‘] = -1;

        $res =  M("{$table}")->where($map)->save($data);
        if( $res ){
            $this->ajaxReturn(array(‘id‘ => 1 ));
        }
}

 

ajax 删除/修改单条数据

标签:hone   success   json   code   rip   turn   blog   color   his   

原文地址:http://www.cnblogs.com/wlbkphp/p/6538627.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!