I can't make JQuery
to wait a second before a function is executed. The JQuery
script shows notification when user
opens a web page. For now, all notifications show immediately but I want them to be added one by one after for example 1000 ms.
I've tried setInterval
and setTimeOut
but nothing worked.
My code - the notifications are still showing at the same time.
function showLobiboxNotification(msg, onClickUrl) {
Lobibox.notify('info', {
title: 'Notification',
delay: false,
msg: msg,
sound: false,
position: 'left bottom',
showClass: 'fadeInDown',
hideClass: 'fadeUpDown',
rounded: 'true',
onClickUrl: onClickUrl
});
setTimeout('showLobiboxNotification', 1000)
}
$(document).ready(function () {
$.ajax({
type: 'GET',
url: "/ajax/get-base-notifications/",
success: function (data) {
$.each(data, function (k, message) {
setTimeout(showLobiboxNotification(message['msg'], message['url']),1000);
});
}
});
});
Do you have any idea?