zoukankan      html  css  js  c++  java
  • laravel框架之状态更改

    //表单
    @if($v['sex']==0)
    <td class="se" ss="{{$v['sex']}}" id="{{$v['id']}}" >男</td>
    @elseif($v['sex']==1)
    <td class="se" ss="{{$v['sex']}}" id="{{$v['id']}}" >女</td>

    @endif

    //jqery
    $(document).on("click",".se",function () {
    id=$(this).attr("id");
    sex= $(this).attr("ss");
    str="";
    if (sex==0){
    str="男"
    }else{
    str="女"
    }

    that=$(this);
    $.ajax({
    url:"jdjg",
    type:"post",
    dataType:"json",
    data:{
    id:id,
    sex:str
    },
    success:function (data) { console.log(data);
    if (data=="男"){
    that.text("男")
    that.attr("ss",0)
    } else{
    that.text("女")
    that.attr("ss",1)
    }


    }
    })
    })



    //控制器
    function   jdjg(req $req){
    $id= $req->post("id");
    $sex=$req->post("sex");
    // echo json_encode($sex);die;
    if ($sex=="男"){
    $res=DB::table("poker")->where("id",$id)->update(["sex"=>1]);
    $sex="女";
    echo json_encode($sex);
    }else{

    $res=DB::table("poker")->where("id",$id)->update(["sex"=>0]);
    $sex="男";
    echo json_encode($sex);
    }






  • 相关阅读:
    hdu 3367 Pseudoforest
    hdu 2489 Minimal Ratio Tree
    hdu 4009 Transfer water
    poj 3164 Command Network
    hdu 3926 Hand in Hand
    hdu 3938 Portal
    5-26日(面经总结)
    5-25日
    5-21日|5-22日
    5-13日记录|5-14日
  • 原文地址:https://www.cnblogs.com/maohongli/p/11185833.html
Copyright © 2011-2022 走看看