嘿嘿哈哈

常用代码
这里作为常用代码收集
扫描右侧二维码阅读全文
15
2018/09

常用代码

这里作为常用代码收集

layui表单ajax提交

form.on('submit(*)', function(data) {
    var formAjaxIndex;
    $.ajax({
        url: data.form.action,
        type: data.form.method,
        beforeSend: function() {
            formAjaxIndex = layer.load(2);
        },
        data: $(data.form).serialize(),
        success: function(json) {
            layer.close(formAjaxIndex);
            if (json.code == 0) {
                layer.msg(json.msg);
            } else {
                layer.msg(json.msg, {
                    time: 2000
                }, function() {
                    if (json.url == '' || json.url == null) {
                        location.reload();
                    } else {
                        location.href = json.url;
                    }
                });
            }
        }
    });
    return false;
});
Last modification:September 15th, 2018 at 10:24 am

Leave a Comment