View Single Post
Old 13th March 2019, 00:07   #23
milosz
Senior Member
 
Join Date: Apr 2006
Location: chicago
Posts: 123
Here it is!!!!

This works - putting this script and tags in the body of my web site shows the upcoming tracks

<script>
var np = {};
np.parse = function(r){

var titles = document.getElementById('titles');
var innerHtml = "";
for(var i = 0; i < r.length; i++){
innerHtml += "<div>" + r[i].title + "</div>"
}
titles.innerHTML=innerHtml;

}
np.jsonp = function(){
var s = document.createElement("script");
s.src="http://MYSTREAMADDRESS:PORTNUMBER/nextsongs?sid=1&json=1&callback=np.parse";
document.body.appendChild(s);
document.body.removeChild(s);
setTimeout( function(){ window.requestAnimationFrame( np.jsonp ) || np.jsonp(); }, 3e4 );
}
np.jsonp();
// setInterval(np.jsonp, 3e4);
</script>

<div align="center">
<div CLASS="para2" align="right"></div>
</div>
<p></p>
<div id="titles">title</div>


=====================================

Many thanks for pointing me to the syntax for &callback that's what was needed to get around the CORS thing
milosz is offline   Reply With Quote