$.ajaxSetup({ cache: false }); $(document).ready(function() { showData(); fetchData(); }); function fetchData() { setTimeout(function() { showData(); fetchData(); }, 3000); } function showData() { $.ajax({ type: “GET”, url: “/ellinikos/NowOnAir.xml”, dataType: “xml”, error: function(e) { alert(“An error occurred while processing XML file”); console.log(“XML reading Failed: “, e); }, success: function (response) { // $(response).find(“Schedule”).each(function() { // $(this).find(“Event”).each(function() { // $(this).find(“Song”).each(function() { // let myText = $(this).attr(“title”); // }); // }); // }); let songTitle = $(response).find(“Song”).attr(“title”); $(“#song”).text(songTitle); let artistName = $(response).find(“Artist”).attr(“name”); $(“#artist”).text(artistName); let imageName = “/ellinikos/CurrentAlbumImage.jpg?random=”+new Date().getTime(); $(“#albumImage”).attr(“src”,imageName); } }); }
By grigoris