Answer the question
In order to leave comments, you need to log in
Instant loading of information from json. How to implement?
I am writing a website for the student radio of my university and came across some difficulty with the implementation of displaying information about the current track.
In icecast, I implemented the output of mount information in json (it looks like this):
{
"response":
{
"name" : "Music",
"listeners" : "12",
"description" : "Description",
"title" : "Soare - all i want",
"genre" : "Ofther",
"url" : "example.com"
}
}
$status = file_get_contents("http://example.com:8000/info.xsl");
$status = json_decode($status);
$track = $status->response;
if ($track->title != null)
{
echo '<marquee behavior="scroll" scrollamount="3" direction="left">'.$track->title.'</marquee>';
} else {
echo 'Error:';
}
function show(url,block)
{
$.ajax({
url: url,
cache: false,
success: function(html){
block.html(html);
}
});
}
$(document).ready(function(){
setInterval(function() { show('getTrack.php',$('#song-title')); } ,5000);
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question