While I have come across a few similar threads, my problem still feels unique to me, so I am hoping for some assistance.
What I am trying to achieve is using a proxy to bypass the same origin policy and retrieve values that change over time, which need to be checked periodically and stored in variables that can be modified.
There is a server with a data file called data.asp that looks something like this and gets updated periodically:
{ "Title":"Tile of song" ,"Artist":"The artist" ,"Album":"The album" ,"CDCover":"/covers/randomcover.jpg" }
I have attempted a method similar to the one outlined on . In case you prefer not to visit the link, I have included the data here as well.
<script>
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","http://www.qnimate.com/ajaxdata.php",true);
xmlhttp.send();
}
</script>
</head>
<body>
<button type="button" onclick="loadXMLDoc()">Request data</button>
<div id="myDiv"></div>
As for the proxy file:
<?php
echo file_get_contents('http://www.qscutter.com/ajaxdata.txt');
?>
My goal is to store the retrieved data in variables that can be updated, rather than displaying it in a div using innerHTML. I would also like to periodically check for any changes in the data.
Any suggestions on how to achieve this?
It's worth mentioning that I have permission from the server owner to access and use the data, but I am unable to add scripts to their server, hence the attempt to bypass the same origin policy using a proxy.