0
I set up a real-time alert script but wanted the alert to appear only once, it loops infinity even clicking close. How do I stop it after the code is executed or how to run only once?
This is my script that checks for new warnings (the big problem):
<script type="text/javascript">
$(document).ready(function(e) {
$.ajaxSetup({
cache:true
});
setInterval(function() {
$('#congelando').load('sy_avisos.php');
}, 1500);
$( "#congelando").click(function() {
$('#congelando').load('sy_avisos.php');
});
});
</script>
This is my script to send the alert with $_POST
:
if ($admin > 4)
{
$alertar = fopen("/sy_avisos.php", "w") or die("Ocorreu um erro ao enviar o
alerta");
$txt = "scriptalert("'.$mensagem.'");script \n";
fwrite($alertar, $txt);
fclose($alertar);
I’m also taking suggestions to make it less complicated, but I’m out of ideas
Big problem is the
setInterval
.– Maury Developer
Is there any way I can do this with Session or something? I’m impatient in this, no ideas, without the break I could not check if there are new warnings
– Victor Stanford
Create a function for flame if you have new alert.
– Maury Developer
Why did you cancel my answer? Did you have a problem?
– Sam
Sorry I pressed wrong I thought I had not validated
– Victor Stanford