Layui 子框架 toast
function myAjaxPost(url, data, successCallback, errorCallback, completeCallback) {
$.ajax({
type: "POST",
url: url,
data: data,
dataType: "json",
beforeSend: function() {
parent.layer.msg("数据正在提交...",
{
icon: 4,
offset: 'rt',
anim: 6,
time: 3000,
skin: "layui-bg-blue"
});
},
success: function(msg) {
if (msg.code === 0) {
parent.layer.msg(msg.message,
{
icon: 1,
offset: 'rt',
anim: 6,
time: 3000,
skin: "layui-bg-green"
},
function() {
if (typeof(successCallback) === 'function') {
successCallback();
}
});
} else {
parent.layer.msg(msg.message,
{
icon: 2,
offset: 'rt',
anim: 6,
time: 3000,
skin: "layui-bg-red"
},
function() {
if (typeof(errorCallback) === 'function') {
errorCallback();
}
});
}
},
error: function(req, status, error) {
parent.layer.msg(error,
{
icon: 2,
offset: 'rt',
anim: 6,
time: 3000,
skin: "layui-bg-red"
},
function() {
if (typeof(errorCallback) === 'function') {
errorCallback();
}
});
},
complete: function() {
if (typeof(completeCallback) === 'function') {
completeCallback();
}
}
});
}

浙公网安备 33010602011771号