Php JQuery墙板,带有声音通知和闪烁的div/table单元格

Php JQuery墙板,带有声音通知和闪烁的div/table单元格,php,jquery,Php,Jquery,我有一个SQL查询页面,在一个大屏幕上显示结果的表中 然后浏览index.php,其中包含以下代码: // <![CDATA[ $(document).ready(function() { // This part addresses an IE bug. without it, IE will only load the first number and will never refresh $.ajaxSetup({ cache: false });

我有一个SQL查询页面,在一个大屏幕上显示结果的表中

然后浏览index.php,其中包含以下代码:

// <![CDATA[
$(document).ready(function() {

    // This part addresses an IE bug. without it, IE will only load the first number and will never refresh
    $.ajaxSetup({ cache: false });    
    setInterval(function() {
        $('.container').load('data.php');
    }, 2000); // the "2000" here refers to the time to refresh the div. it is in milliseconds.
});
// ]]>
//
HTML:

<div class="container"><h3>Loading Data...</h3></div>
正在加载数据。。。
所以它会不断地加载这个页面

我想做的是,如果任何查询包含需要对其采取行动的数据,表格单元格将闪烁2种颜色,并且每5分钟播放一次声音

要做到这一点并保持恒定的页面加载,最好的方法是什么?

我会将.load()更改为ajax调用,完成后调用函数。检查以下脚本:

// Prepare the audio - replace the link with your own mp3
var audioElement = document.createElement('audio');
audioElement.setAttribute('src', 'http://www.uscis.gov/files/nativedocuments/Track%2090.mp3');

// Global that will control the flashing / playing of sound
var alertUser = false;
$(document).ready(function() {
    $.ajaxSetup({ cache: false });      // Fix IE bug
    setInterval(function(){
        $.ajax({
            url: "data.php",
            complete: function( jq, content ){
                $('.container').html( jq.response );
                if( jq.response.indexOf( 'from' ) != -1 ) { // your logic goes here to decide the warning
                    alertUser = true;
                } else {
                    alertUser = false;
                }
            }
        }); 
    }, 2000);

    setInterval(function(){
        if( alertUser ) {
            // play tune
            audioElement.play();

            // flash background
            window.setTimeout( function(){
                $('.container').css('background-color','red')
            }, 200 );
            window.setTimeout( function(){
                $('.container').css('background-color','blue')
            }, 400 );
            window.setTimeout( function(){
                $('.container').css('background-color','transparent')
            }, 600 );
        }
    }, 1000);
});