need to play sound on different content, but it’s playing sound every time
only one echo in get.php work fine and if i change code in get.php to parser code it
act’s like content is not the same all time
#
html body code
#
<div id="main"><?php include("ajax/get.php");?></div>
<audio id="sound" src="sound/sound.ogg" controls type="audio/ogg" preload="auto" autobuffer></audio>
<script type="text/javascript">
var audio=document.getElementById("sound");
setInterval(function()
{
$.get('ajax/get.php',function(data){
if ($('#main').html() !== data){
$('#main').html(data);
audio.play();
}
});
}, 5000);
</script>
#
php parser code
#
require_once('simple_html_dom.php');
$html=file_get_html('supersite-content');
$ret = $html->find('.request');
foreach ($ret as $key) {
echo "$key</br></br>";
}
The Browser modifies the html mostly on render time so it is not the same as in textual form. You can add a cache to compare the original string. Something like this: