我在桌面上有一个带有SQL查询的页面,可以在大屏幕上显示结果.
// <![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调用,该调用在完成后调用函数.检查下面的脚本:
原文链接:https://www.f2er.com/php/136616.html// 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); });