SWRNET adlı üyeden alıntı: mesajı görüntüle
kodunuzu şu şekilde güncelleyebilirseniz, çalışabilir.

js:

var audio = new Audio('Girtab.mp3');
setInterval(function() {
    // Veritabanını kontrol etmek için Ajax isteği gönder
    var xhr = new XMLHttpRequest();
    xhr.open('POST', 'veritabani_kontrol.php');
    xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xhr.onload = function() {
        if (xhr.status === 200) {
            // Veritabanında yeni veri varsa, sayfayı yenile
            if (xhr.responseText === '1') {
                audio.play();
                setTimeout(function() {
                    location.reload();
                }, 2000);
            }
        }
    };
    xhr.send();
}, 5000);

php

<?php
header("Content-Type: text/plain");

try {
    include("connect.php");
    // Veritabanındaki son siparişin zaman bilgisini al
    $stmt = $baglan->prepare("SELECT zaman FROM siparisonay ORDER BY id DESC LIMIT 1");
    $stmt->execute();
    $zaman = $stmt->fetchColumn();
    // Eğer son sipariş 5 dakikadan önce yapılmışsa yeni veri yoktur
    if (time() - strtotime($zaman) > 300) {
        echo 0;
    } else {
        echo 1;
    }
} catch (PDOException $e) {
    echo "Hata: " . $e->getMessage();
}
?>
hocam denedim hala herhangi bir değişiklik yok istek gönderiyor ancak geri bi tepki alamıyorum