$(document).ready(function(){
var content = document.getElementById('playing');
var call = function(){
$.ajax({
method:'POST',
url:'radio/player/data/playing.php',
success:function(data){
content.innerHTML = data;
setTimeout(call, 30000); // 30s.
}
});
}
call();
});
Używam kilkanaście takich kodów na stronie. Po dłuższym czasie niektóre z kodów się zawieszają. Można jakoś je ulepszyć, żeby się nie zawieszały ? LINK do strony
<?php
/* ----------- Polish text and different signs ---------- */
header('Content-type: text/html; charset=windows-1250');
?>
<?php
/* ----------- Server configuration ---------- */
$ip = "s8.myradiostream.com";
$port = "7882";
/* ----- No need to edit below this line ----- */
/* ------------------------------------------- */
$fp = @fsockopen($ip,$port,$errno,$errstr,1);
if (!$fp)
{
echo "Consciousness - We are not playing now"; // Diaplays when sever is offline
}
else
{
fputs($fp, "GET /7.html HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n");
while (!feof($fp))
{
$info = fgets($fp);
}
$info = str_replace('</body></html>', "", $info);
$split = explode(',', $info);
if (empty($split[6]) )
{
echo "Consciousness - We are not playing now"; // Diaplays when sever is online but no song title
}
else
{
$title = str_replace('\'', '`', $split[6]);
$title = str_replace(',', ' ', $title);
echo "$title"; // Diaplays song
}
}
?>