i am trying to get notifications for a small project of mine using setTimeout but it requires me to get two types of notification 1. messages 2.global so i had to write two functions , is this possible to use two setTimeout under one function here is what i coded
// Message Notification Poll
(function pollmsg() {
setTimeout(function () {
var demon = $('.msgnotimore').val();
var page = "notimsg";
var a = $('.gvpgvpxgvp').val();
$.ajax({
url: 'modules/notifications/beast.php?nid=' + demon + '&id=' + a + '&page=' + page,
success: function (html) {
if ($.trim(html) == 'no') {}
else {
$('.msgnotimore').remove();
$('.notiloadmsg').prepend($(html).fadeIn('slow'));
}
},
dataType: "html",
complete: pollmsg
});
}, 60000);
})();
// Global Notification Poll
(function pollglobal() {
setTimeout(function () {
var demon = $('.globalnotimore').val();
var page = "notiglobal";
var a = $('.gvpgvpxgvp').val();
$.ajax({
url: 'modules/notifications/beast.php?nid=' + demon + '&id=' + a + '&page=' + page,
success: function (html) {
if ($.trim(html) == 'no') {}
else {
$('.globalnotimore').remove();
$('.notiloadglobal').prepend($(html).fadeIn('slow'));
}
},
dataType: "html",
complete: pollglobal
});
}, 60000);
})();
I think you’re asking ‘is it ok to have two setTimeouts running at once’?
If this is the question then the answer is yes, you can have as many setTimeouts running at once as you like. I believe the only limit is memory.