So, for any page you are on, you must add an ajax function that runs a PHP script that executes the request. If it returns true, activate the javascript function that plays the sound. If it returns false, there is no sound. Here is an example with jquery:
function checkOrders() { $.get('checkOrders.php', function(data) { if(data.neworders == true) { audio.play(); } } }); t=setTimeout("checkOrders()",(5 * 60 * 1000)); } $(function() { checkOrders(); });
It is assumed that you are returning data from php as json and that you have already created an audio object as suggested by Delan earlier.
My javascript / jquery is a little rusty, feel free to comment or edit errors.
source share