ajax提交表单

 
<form id="parkSys_bind_edit_form" name="parkSys_bind_edit_form" method="POST"
          action="{:url('card/savepost')}">
 

        <ul class="addinput">
            <li><span>绑定方式:</span>
                <div class="dis-ib">
                    <em>
                    <input type="radio" value="0" name="reserveType"  id="radio1" checked  class="shoujiradio">
                    <label for="radio1">手机绑定</label> 
                     
                    </em>

                    <em> <input  type="radio" value="1" name="reserveType" id="radio2" class="chepairadio">
                        <label for="radio2">绑定车牌</label> 

                    </em>
                </div>
            </li>
            <li class="shouji" style="display:none;"><span>手机查询:</span>
                <input type="text"   name="checkPhone" id="checkPhone" class="s1 grey" maxlength="11">
                <input type="button" class="button_search btn btn-primary" onclick="selectMember()" value="查询">
            </li>
            <li class="chepai" style="display:none;"><span>车牌查询:</span>
                <select id="memberType" name="memberType" class="gray" style="width:70px">
                    <option value="">-请选-</option>
                    <option value="京">京</option> 
                    </select>
                <input type="text" value="" name="checkNumber" id="checkNumber" class="s1 grey" maxlength="50">
                <input type="button" class="button_search   btn-primary"  style="height:28px" onclick="selectMember()" value="查询">
            </li>
            <li><span>会员姓名:</span>
                <em id="reserveNamestrr"></em>
                <input type="hidden" name="username" id="cardHolder" class="s1 grey " maxlength="50"/>
                <input type="hidden" name="user_id" id="memberId" class="s1 grey " maxlength="50"/>
            </li>

            <li><span>默认有效期至 :</span><em>2021-01-01</em></li>

            <input type="hidden" id="endtime" name="endtime" value="2021-01-01"/>
            <input type="hidden" id="newDate" name="newDate" value=""/>

            <!-- <li><span>有效期 :</span>
                   <input id="bindTimestr"  name="bindTimestr" class="laydate-icon form-control layer-date">
              
            </li> -->
                <li class="clear mt30"><span></span>
                <input type="hidden" name="id" value="{$bind_id}" >
                <input type="submit" id="reserveSaveBtn" value="保存" name="B1" class=" btn btn-primary">
         </li>
            <script src="__ADMIN__/js/plugins/layer/laydate/laydate.js"></script>
            <script type="text/javascript">
                //外部js调用
                // laydate({
                //     elem: '#bindTimestr',
                //     event: 'focus'
                // });
            </script>
            <script type="text/javascript">
                 $(".shouji").show();
                $(".chepai").hide();
                $("#checkNumber").val("");
                $("#reserveNamestrr").html("");
                $(".shoujiradio").click(function () {
                    $(".shouji").show();
                    $(".chepai").hide();
                    $("#checkNumber").val("");
                    $("#reserveNamestrr").html("");
                })
                $(".chepairadio").click(function () {
                    $(".chepai").show();
                    $(".shouji").hide();
                    $("#checkPhone").val("");
                    $("#reserveNamestrr").html("");
                })
            </script>

        </ul>
    </form>

    <script type="text/javascript">

        $('#parkSys_bind_edit_form').submit(function() {
            var url = "{:url('card/savepost')}"; 
            var _this = $(this);
            var data = _this.serialize();
            var username = $("#cardHolder").val();
            if(!username){
                layer.msg('请选着要绑定的会员姓名');
            }

            // return false;

            $.ajax({
                url: url,
                type: 'post',
                data:  data ,
                dataType: "json",
                success:function(rs){   
                    // console.log(rs.code);
                    // console.log(rs);
                   if(rs.code==200){
                        showMsg(rs.msg);
                        // layer.msg(rs.msg);
                        // window.location.href = "{:url('card/index')}";
                        window.parent.location.reload();
                        return false;
                   }else{
                        showMsg(rs.msg)
                   }
                }
            });

            return false;
        });
    </script>

  

posted @ 2020-11-23 13:35  Abner3721  阅读(73)  评论(0编辑  收藏  举报