View Single Post
Old 09-09-2007, 09:44 PM   PM User | #2
rwedge
Regular Coder

 
Join Date: Feb 2005
Posts: 679
Thanks: 0
Thanked 16 Times in 15 Posts
rwedge is on a distinguished road
As long as the radio server file is available locally you could use AJAX.

example:
Code:
<script type="text/javascript">
/*<![CDATA[*/
var xmlHttp, timer, url = 'radioserver.txt';
function ajaxRequest() {
if (timer) {
  clearTimeout(timer);
}
try {
     xmlHttp = new XMLHttpRequest();
} catch(e) {
try {
     xmlHttp = new ActiveXObject('MSXML2.XMLHTTP.3.0'); 
} catch(er) {
     // alert("Could Not Initiate HTTPRequest!");
     return;
}
}
xmlHttp.onreadystatechange = function() { 
if(xmlHttp.readyState == 4)  {
 if (xmlHttp.status == 200) {
   handleRequest(xmlHttp);
 } else {
   handleError(xmlHttp);
 }
} 
}; 
xmlHttp.open("GET", url + '?' + Math.random(), true);
xmlHttp.send(null);
}
function handleRequest(txt) {
if (txt.responseText) {
var target_ele = document.getElementById('song_info');
var newTxt = document.createTextNode(txt.responseText);
var ochild = target_ele.childNodes[0];
    ochild.parentNode.replaceChild(newTxt, ochild);
}
timer = setTimeout(ajaxRequest, 10000); // 10 seconds
}
function handleError(err) {
// alert('A ' + err.status + ' Error Occurred.\nError Message: ' + err.statusText);
return;
}
window.onload = function() {
ajaxRequest();
};
/*]]>*/
</script>

  ...

<table>
 <tbody>
  <tr>
    <td>first cell contents</td><td id="song_info">default value</td><td>third cell contents</td>
  </tr>
 </tbody>
</table>

Last edited by rwedge; 09-10-2007 at 12:58 AM.. Reason: occurred spelling
rwedge is offline   Reply With Quote