Hello i am trying to create a PHP page that can be called by ajax from anonymous host, I run my code XAMPP host and working nice, But when i try to run it from http://podserver.info/
means I take a free hosting from there, it is www.datatwo.podserver.info
. I use the following PHP code
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
header('Access-Control-Allow-Headers: Origin, Content-Type, Accept,Authorization, X-Request-With');
header('Access-Control-Allow-Credentials: true');
echo "hi";
?>
and JavaScript ajax code is
var xmlhttp;
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
console.log(xmlhttp.responseText);
}
}
xmlhttp.open("GET", "//www.datatwo.podserver.info/index.php", true);
xmlhttp.send();
but it only work when I use XAMPP server and when I upload it to pod server it dos not work, what can I do now?
A error message from console XMLHttpRequest cannot load http://www.datatwo.podserver.info/index.php. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://stackoverflow.com' is therefore not allowed access.