【layUI杂记】layui之点击注册或者提示成功,只刷新table

" class="wiz-editor-body wiz-readonly" data-wiz-document-type="common" spellcheck="false" contenteditable="false">
// 提交按钮事件
form.on('submit(demo1)', function (data) {
var starttime = data.field['starttime'];
var endtime = data.field['endtime'];
var local = data.field['local'];
var type = data.field['type'];
var content = $('#content').val();
$.ajax({
    'type': 'post',
    'url': '${SITE_URL}news/to/do/strings/',
    'data': {
        'starttime': starttime,
        'endtime': endtime,
        'local': local,
        'type': type,
        'content': content
    },
    'success': function (data) {
-------------  返回成功后的代码,不要用alert而是使用msg -------------------
        if(data['retCode'] == 2001){ 
            layer.msg(data['retMsg'], {icon: 1}, function () {
                table.render({
                    elem: '#test'
                    , width: 750
                    , height: 200
                    , skin: 'row'
                    , url: '${SITE_URL}news/day/to/do/'
                    , method: 'post'
                    , cellMinWidth: 80 //全局定义常规单元格的最小宽度,layui 2.2.1 新增
                    , cols: [[
                        {field: 'start', width: 120, title: '开始', sort: true}
                        , {field: 'end', width: 120, title: '结束'}
                        , {field: 'content', title: '内容', sort: true}
                        , {field: 'status', width: 80, title: '状态', templet: '#course2'}
                        , {field: 'local', title: '地点', width: 120, minWidth: 100} //minWidth:局部定义当前单元格的最小宽度,layui 2.2.1 新增
                        , {field: 'right', title: '操作', width: 120, toolbar: '#barDemo'}
                    ]]
                    , page: true
                    , text: {
                        none: '暂无相关数据'
                    }
                    , limit: 3
                });
            })
------------------------------------------------------------------------------------------
        } else if(data['retCode'] == 7001){
            layer.alert(data['retMsg'], {icon: 2, time: 2000})
        } else if(data['retCode'] == 7002){
            layer.alert(data['retMsg'], {icon: 2, time: 2000})
        } else if(data['retCode'] == 7003){
            layer.alert(data['retMsg'], {icon: 2, time: 2000})
        } else if(data['retCode'] == 3006){
            layer.alert(data['retMsg'], {icon: 2, time: 2000})
        }
    }
});
});
posted @ 2022-04-26 15:06  郭祺迦  阅读(275)  评论(0)    收藏  举报