<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
    <h4 class="modal-title">添加管理员</h4>
</div>
<form id="add_form" class="form-horizontal" autocomplete="off">
    <div class="modal-body">
        <div class="input-group">
            <span class="input-group-addon">用户名</span>
            <input id="username" name="MemberForm[username]" type="text" class="form-control" placeholder="用户名" autocomplete="off">
        </div>
        <div class="hr-line-dashed"></div>
        <div class="input-group">
            <span class="input-group-addon">&nbsp;&nbsp;&nbsp;姓名</span>
            <input id="name" name="MemberForm[name]" type="text" class="form-control" placeholder="姓名" autocomplete="off">
        </div>
        <div class="hr-line-dashed"></div>
        <div class="input-group">
            <span class="input-group-addon">&nbsp;&nbsp;&nbsp;密码</span>
            <input id="password" name="MemberForm[password]" type="text" class="form-control" placeholder="密码" autocomplete="off">
        </div>
        <div class="hr-line-dashed"></div>
        <div class="input-group">
            <span class="input-group-addon">&nbsp;&nbsp;&nbsp;手机</span>
            <input id="mobile" name="MemberForm[mobile]" type="number" class="form-control" placeholder="手机号码" autocomplete="off">
        </div>
        <div class="hr-line-dashed"></div>
    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-white" data-dismiss="modal">取消</button>
        <button id="add_submit" type="button" class="btn btn-primary">提交</button>
    </div>
</form>


<script type="text/javascript">
$("#add_submit").on("click",function(){
    $.ajax({
        type: "POST",
        url: "/admin/admin/save",
        data: $('#add_form').serialize(),
        dataType: "json",
        beforeSend: function() {},
        success: function(data) {

            if(data.code == 1){
                $("#modal").modal("hide");
                table.ajax.reload();
            }else{
                toastr.error(data.message, "提示");
            }

        },
        complete: function(XMLHttpRequest, textStatus) {},
        error: function() {}
    });
});

$(function () {
    setTimeout(function () {
        $('#password').attr('type', 'password');     
    }, 1000);
});

</script>
