實現功能:
執行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";
});