实现功能:
执行ajax成功后,要实现里面有个提示信息,layer.msg,然后跳转到另一个页面
错误代码:
layer.msg("xxx成功!", {time: 1000,});
window.location.href = "xxx.html";
错误描述:
layer.msg没有弹出来就直接跳转了
错误原因:
错误代码中,弹出层和跳转页面同时执行了,所以看不到弹出信息
正确代码:
//1、跳转页面在layer.msg里面的end中执行
layer.msg("xxx成功!", {
time: 1000,
end: function(){
window.location.href = "xxx.html";
}
});
//2、跳转页面在function中执行
layer.msg("xxx成功!", {time: 1000},
function(){
window.location.href = "xxx.html";
});