Ajax异步 无刷新修改数据传值部分

//修改商品

//把返回值放入表单中做默认值
function do_editgoods(id){
    $('#editgoods').modal('open');
    $.get('/Home/Price/edit/item_id/'+id,function(result){
       document.getElementById("hid").value = result.content['id'];
       document.getElementById("item_id").value = result.content['item_id'];
       document.getElementById("outer_item_id").value = result.content['outer_item_id'];
       document.getElementById("goods_name").value = result.content['goods_name'];
       document.getElementById("standard").value = result.content['standard'];
       document.getElementById("low_price").value = result.content['low_price'];
       document.getElementById("minus_price").value = result.content['minus_price'];
       document.getElementById("moni_url").value = result.content['moni_url'];
    },'json');
    return false;
}


//将表单的默认值通过异步传到控制器

function do_edit(){

    $.post(
        '/Home/Price/to_edit',
        {   'hid':$(".edit_hid").val(),
            'item_id':$(".edit_item_id").val(),
            'outer_item_id':$(".edit_outer_item_id").val(),
            'goods_name':$(".edit_goods_name").val(),
            'standard':$(".edit_standard").val(),
            'low_price':$(".edit_low_price").val(),
            'minus_price':$(".edit_minus_price").val(),
            'moni_url':$(".edit_moni_url").val()
        },function(result){
            if(result.code == 200){
                //$("#msg1").cl
                $("#msg2").addClass('am-text-success');
                $("#msg2").html('修改成功!');
                $("#msg2").html(result.msg);
                //window.location.href="/Home/Index/index.html";
            }else{
                //$("#msg1").addClass('am-text-danger');
                $("#msg2").html(result.msg);
            }

    },'json');

}


//控制器进行处理----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

  /**
     * 修改商品价格
     */
    
    public function edit(){
    $map['item_id'] = $_GET['item_id'];                 //获取页面传过来的商品编号
    $to_display = M('haoyao_price_compare') -> where($map) -> find();      //查处所需要的信息
//成功后返回客户端新增的用户ID,并返回提示信息和操作状态
$this->ajaxReturn(array('code'=>200,'content'=>$to_display)); //将获取到的数据返回到页面
    }


    public function to_edit(){
    $map['id'] = $_POST['hid']; //获取页面传过来的商品编号
    $data['item_id'] = $_POST['item_id']; //获取页面传过来的商品编号
    $data['outer_item_id'] = $_POST['outer_item_id']; //获取页面传过来的外部商家编号
$data['goods_name'] = $_POST['goods_name']; //获取页面传过来的商品名称
$data['standard'] = $_POST['standard']; //获取页面传过来的商品规格
$data['low_price'] = $_POST['low_price']; //获取页面传过来的商品最低价格
$data['modi_time'] = date('Y-m-d H:i:s',time()); //获取页面传过来的商品修改时间
$data['minus_price'] = $_POST['minus_price']; //获取页面传过来的商品优惠价格
$data['mino_url'] = $_POST['moni_url']; //获取页面传过来的商品链接


$res = M('haoyao_price_compare')->where($map)->save($data);
if($res){
$this->ajaxReturn(array('code'=>200));
}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值