I've made .js program which makes baners on pages i own (each page is posted on different server). I'm using <script src="sample.com"></script>
to run it.
The problem is, my script requests main server (on which file with script is hosted) for some variables and than I get message:
Origin http://php.kotarbki.pl is not allowed by Access-Control-Allow-Origin.
I can't turn on Access-Control-Allow-Origin on server I use, but isn't it some way to work-around it, I mean this script is hosted on the server that is requesting!
-------------SERVER1---------------server-first.com---------------
script.js file:
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp=new XMLHttpRequest();
}else{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
return xmlhttp.responseText.split("#");
}
}
xmlhttp.open("GET","http://server-first.com/page.php?action=getVariables",true);
xmlhttp.send();
page.php file:
if($_GET['action']=='getVariables'){
echo $var1 . "#" . $var2;
}
-------------SERVER2---------------second-server.com---------------
<html>
<script src="server-first.com/script.js"></script>
</html>