Skip to content

Instantly share code, notes, and snippets.

@aleckyann
Created June 23, 2021 17:57
Show Gist options
  • Save aleckyann/c28aac70be79fdadf8511d994b891ef5 to your computer and use it in GitHub Desktop.
Save aleckyann/c28aac70be79fdadf8511d994b891ef5 to your computer and use it in GitHub Desktop.
BENK POOLING POOL
<script>
$(document).ready(function() {
/**
* Pooling pool para verificar se existem NOTIFICACAO NO DB != 0
* Se houver mostra alerta
*/
function refreshChatWhatsappAlert() {
$.ajax({
method: "POST",
url: "URL-ONDE-PEGA-STATUS",
data: {
"NOTIFICACAO_ID": '1'
}
}).done(function(notificacoes) {
notificacoes = JSON.parse(notificacoes);
if (notificacoes > 0) {
//SE HOUVER MAIS DE UMA ATUALIZAÇÃO
} else {
SE NÃO HOUVR NENHUMA
}
setTimeout(refreshChatWhatsappAlert, 10000); //10 SEGUNDOS ENTRE CONSULTAS
});
}
setTimeout(refreshChatWhatsappAlert, 3000); //3 SEGUNDOS PARA PRIMEIRA CONSULTA
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment