1. 程式人生 > >layui點擊彈框頁面 表單請求

layui點擊彈框頁面 表單請求

點擊 .post msg inline nbsp ces 相關 block mes

$("#addSite").click(function () {
    layer.open({
        title: ‘添加站點‘,
        type: 1,
        area: [‘700px‘, ‘400px‘],
        content: ‘<blockquote class="layui-elem-quote layui-text">註意事項: 請填寫相關的數據信息! </blockquote>‘ +
        ‘<form class="layui-form"> ‘ +
        ‘<div class="layui-form-item">‘ +
        ‘<div class="layui-inline">‘ +
        ‘<label class="layui-form-label">站點名稱</label>‘ +
        ‘<div class="layui-input-inline">‘ +
        ‘<input type="text"  required lay-verify="required" name="siteName"  class="layui-input" value="" >‘ +
        ‘</div></div>‘ +
        ‘<div class="layui-inline">‘ +
        ‘<label class="layui-form-label">ICP備案號</label>‘ +
        ‘<div class="layui-input-inline">‘ +
        ‘<input type="text"  required lay-verify="required" name="fileRecord"    class="layui-input" value="" >‘ +
        ‘</div></div>‘ +
        ‘</div>‘ +
        ‘<div class="layui-form-item">‘ +
        ‘<div class="layui-inline">‘ +
        ‘<label class="layui-form-label">聯系電話</label>‘ +
        ‘<div class="layui-input-inline">‘ +
        ‘<input type="text"  required lay-verify="required" name="sitePhone"  class="layui-input" value="" >‘ +
        ‘</div></div>‘ +
        ‘<div class="layui-inline">‘ +
        ‘<label class="layui-form-label">平臺信息</label>‘ +
        ‘<div class="layui-input-inline">‘ +
        ‘<input type="text"  required lay-verify="required" name="type"    class="layui-input" value="" >‘ +
        ‘</div></div>‘ +
        ‘</div>‘ +
        ‘<div class="layui-form-item" style="width: 621px;">‘ +
        ‘<label class="layui-form-label">備註</label>‘ +
        ‘<div class="layui-input-block">‘ +
        ‘<textarea placeholder="請輸入內容" name="siteMark" class="layui-textarea"></textarea>‘ +
        ‘</div>‘ +
        ‘</div>‘ +
        ‘</form>‘,
        btnAlign: 
‘c‘, btn: [‘確定‘, ‘取消‘], yes: function (index, layero) { var str = $("input[name=isIndividual]").val(); if (str == "on") { str = "1"; } else { str = "0"; } if ($("input[name=siteName]").val() == null
|| $("input[name=siteName]").val() == "") { layer.msg(‘請輸入站點名稱‘, {icon: 5, time: 2000, area: ‘200px‘, type: 0, anim: 6,}, function () { $("input[name=siteName]").focus(); }); return false; } else if ($("input[name=fileRecord]").val() == null
|| $("input[name=fileRecord]").val() == "") { layer.msg(‘請輸入備案號‘, {icon: 5, time: 2000, area: ‘200px‘, type: 0, anim: 6,}, function () { $("input[name=fileRecord]").focus(); }); return false; } else if ($("input[name=type]").val() == null || $("input[name=type]").val() == "") { layer.msg(‘請輸入平臺信息‘, {icon: 5, time: 2000, area: ‘200px‘, type: 0, anim: 6,}, function () { $("input[name=type]").focus(); }); return false; } else if ($("input[name=sitePhone]").val() == null || $("input[name=sitePhone]").val() == "") { layer.msg(‘請輸入聯系電話‘, {icon: 5, time: 2000, area: ‘200px‘, type: 0, anim: 6,}, function () { $("input[name=sitePhone]").focus(); }); return false; } var formData = { siteName: $("input[name=siteName]").val(), fileRecord: $("input[name=fileRecord]").val(), type: $("input[name=type]").val(), sitePhone: $("input[name=sitePhone]").val(), siteMark: $("textarea[name=siteMark]").val() }; console.log(formData); $.post(‘${pageContext.request.contextPath}/leaguer/addSite‘, formData, function (data) { //判斷是否發送成功 if (data.code == 200) { layer.msg(data.message); layer.close(index); parent.document.getElementById(‘my_iframe‘).contentWindow.location.reload(true); } else { layer.msg("保存失敗...", {type: 1}); } }) }, btn2: function (index, layero) { layer.msg("取消"); //return false 開啟該代碼可禁止點擊該按鈕關閉 }, cancel: function () { layer.msg("關閉窗口"); //右上角關閉回調 //return false 開啟該代碼可禁止點擊該按鈕關閉 }, success: function () { layui.use(‘form‘, function () { var form = layui.form; //只有執行了這一步,部分表單元素才會修飾成功 form.render(‘checkbox‘); form.on(‘checkbox(istrue)‘, function (data) { /* if(data.elem.checked){ emailConfig[‘isenterprise‘]=1; }; //是否被選中,true或者false*/ }); }); } }); })

layui點擊彈框頁面 表單請求